While writing this method for a custom NUnit Constraint.
private void AddMatchFailure(string failureName, TExpected expected, TActu
private void AddMatchFailure(string failureName, TExpected expected, TActual actual)
{
_matchFailures.Add(
String.Format(MatchFailureFormat, failureName,
(expected == default(TExpected)) ? "null" : expected.ToString(),
(actual == default(TActual)) ? "null" : actual.ToString()));
}
Should do it.
default(T)
gives the default value for that type, for reference types that's null - for others it depends. (Enums it's the equivalent of (enumType)0
for example).