/// <summary>
 /// Last part of the .To.Be.Equal.To() chain
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="expected">Expected value</param>
 /// <param name="customMessageGenerator">Generates a custom message to include when failing</param>
 /// <typeparam name="T">Object type being tested</typeparam>
 public static IMore <T> To <T>(
     this IEqualityContinuation <T> continuation,
     T expected,
     Func <string> customMessageGenerator
     )
 {
     return(continuation.AddMatcher(
                actual =>
     {
         var passed = (actual == null && expected == null) ||
                      (actual?.Equals(expected) ?? false);
         return new MatcherResult(
             passed,
             FinalMessageFor(
                 () => new[]
         {
             "Expected",
             Quote(actual),
             $"{passed.AsNot()}to equal",
             Quote(expected)
         },
                 customMessageGenerator
                 ));
     }));
 }
 /// <summary>
 /// Last part of the .To.Be.Equal.To() chain
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="expected">Expected value</param>
 /// <typeparam name="T">Object type being tested</typeparam>
 public static IMore <T> To <T>(
     this IEqualityContinuation <T> continuation,
     T expected
     )
 {
     return(continuation.To(expected, NULL_STRING));
 }
示例#3
0
 /// <summary>
 /// Last part of the .To.Be.Equal.To() chain
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="expected">Expected value</param>
 /// <typeparam name="T">Object type being tested</typeparam>
 public static void To <T>(
     this IEqualityContinuation <T> continuation,
     T expected
     )
 {
     continuation.To(expected, NULL_STRING);
 }
 /// <summary>
 /// Last part of the .To.Be.Equal.To() chain
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="expected">Expected value</param>
 /// <param name="customMessage">Custom message to include when failing</param>
 /// <typeparam name="T">Object type being tested</typeparam>
 public static IMore <T> To <T>(
     this IEqualityContinuation <T> continuation,
     T expected,
     string customMessage
     )
 {
     return(continuation.To(expected, () => customMessage));
 }
示例#5
0
 /// <summary>
 /// Last part of the .To.Be.Equal.To() chain
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="expected">Expected value</param>
 /// <param name="customMessage">Custom message to include when failing</param>
 /// <typeparam name="T">Object type being tested</typeparam>
 public static void To <T>(
     this IEqualityContinuation <T> continuation,
     T expected,
     string customMessage
     )
 {
     continuation.To(expected, () => customMessage);
 }
示例#6
0
 public static void To <T>(
     this IEqualityContinuation <T> continuation,
     T expected
     )
 {
     continuation.AddMatcher(actual =>
     {
         var passed  = actual.Equals(expected);
         var message = passed
             ? $"Expected {Quote(actual)} not to equal {Quote(expected)}"
             : $"Expected {Quote(actual)} to equal {Quote(expected)}";
         return(new MatcherResult(passed, message));
     });
 }