I expect both tests below (written for NUnit) to pass, but the Decimal version fails with, "System.FormatException: Format specifier was invalid", as does a Double version. I cannot figure out why. Can someone please shed light?
Thanks; Duncan
[Test]
public void Integer_Format_Hex()
{
//Assume
Int32 myValue = 11101110;
//Arrange
//Act
//Assert
Assert.That( String.Format( "0x{0:X8}" , myValue ) , Is.EqualTo( "0x00A963B6" ) );
}
[Test]
public void Decimal_Format_Hex()
{
//Assume
Decimal myValue = 11101110m;
//Arrange
//Act
//Assert
Assert.That( String.Format( "0x{0:X8}" , myValue ) , Is.EqualTo( "0x00A963B6" ) );
}
[Test]
public void Decimal_Format_Hex2()
{
//Assume
Decimal myValue = 11101110m;
//Arrange
//Act
//Assert
Assert.That( myValue.ToString( "X" ) , Is.EqualTo( "00A963B6" ) );
}