Summary
When a test failure is reported by Assert.IsNull(...), no information is provided on the actual value.
Background and Motivation
When you assert that a given "value" (object reference) is null, the failure that is reported when it isn't null could provide more information on the "value".
This is definitely useful if the type of value implements IFormattable or is a nullable value type for which the underlying type implements IFormattable.
To reproduce, run the following test class:
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class Foo
{
[TestMethod]
public void IsNull()
{
string actual = "XX";
Assert.IsNull(actual);
}
}
Expected behavior
The following test failure is reported:
Assert.IsNull failed. Expected:<null>. Actual:<XX>. 'value' expression: 'actual'.
Actual behavior
The following test failure is reported:
Assert.IsNull failed. 'value' expression: 'actual'.
Summary
When a test failure is reported by
Assert.IsNull(...), no information is provided on the actual value.Background and Motivation
When you assert that a given "value" (object reference) is null, the failure that is reported when it isn't null could provide more information on the "value".
This is definitely useful if the type of value implements IFormattable or is a nullable value type for which the underlying type implements IFormattable.
To reproduce, run the following test class:
Expected behavior
The following test failure is reported:
Assert.IsNull failed. Expected:<null>. Actual:<XX>. 'value' expression: 'actual'.Actual behavior
The following test failure is reported:
Assert.IsNull failed. 'value' expression: 'actual'.