This is apparently a function mistakeMSTest. When you repeat the test with NUnitor simply with, an operator ==implicit conversion is performed.
MSTest Assert boils down to:
Assert.AreEqual<object>(expected, actual, message, parameters);
public static void AreEqual<T>(T expected, T actual, string message, params object[] parameters)
{
message = Assert.CreateCompleteMessage(message, parameters);
if (object.Equals((object) expected, (object) actual))
return;
Assert.HandleFailure ...
}
Premature boxing through objectis most likely the culprit.
, MSTest T, :
Assert.AreEqual<sbyte?>(nullableSbyte, 127);
.
, NUnit Assert - :
[Test]
public void SByte()
{
sbyte? nullableSbyte = sbyteValueFromByte;
Assert.AreEqual(nullableSbyte.Value, 127);
Assert.AreEqual(nullableSbyte, 127);
}
unit test:
sbyte? nullableSbyte = sbyteValueFromByte;
if (nullableSbyte.Value != 127)
{
throw new Exception("Not Equal");
}
if (nullableSbyte != 127)
{
throw new Exception("Not Equal");
}
Edit
