private static IVerificationTarget <bool?> ExpectBooleanValue( IVerificationTarget <bool?> target, bool?expectedValue, FormattableString?message) { return(CallbackAssertion.Create( target, context => { if (target.Value == expectedValue) { return true; } var writer = context.Writer; context.WriteMessage(message); using (writer.Indent()) { writer.WriteLine($"Expected: {expectedValue}"); writer.WriteLine($"But was: {target}"); } return false; })); }
/// <summary> /// Verifies that the given value is not null. /// </summary> public static IVerificationTarget <T?> NotNull <T>( this IVerificationTarget <T?> target, FormattableString?message = null) where T : struct { return(CallbackAssertion.Create( target, context => { if (!target.Value.HasValue) { return true; } context.WriteMessage(message); using (context.Writer.Indent()) { context.Writer.WriteLine($"Expected: not <null>"); context.Writer.WriteLine($"But was: <null>"); } return false; })); }