/// <summary> /// Test the value matched by a prior key match for deep equality /// with another object /// </summary> /// <param name="continuation">Continuation to operate on</param> /// <param name="otherValue">Value to test deep equality against</param> /// <param name="customMessageGenerator">Custom failure message generator</param> /// <typeparam name="T">Type of the dictionary-sourced value</typeparam> /// <returns></returns> public static IMore <T> To <T>( this IDictionaryValueEqual <T> continuation, object otherValue, Func <string> customMessageGenerator) { continuation.AddMatcher(actual => { var isDeep = continuation.GetMetadata( DictionaryValueEqual <T> .DICTIONARY_VALUE_DEEP_EQUALITY_TESTING, true ); var tester = new DeepEqualityTester( actual, otherValue); if (!isDeep) { tester.OnlyTestIntersectingProperties = true; } var passed = tester.AreDeepEqual(); return(new MatcherResult( passed, FinalMessageFor( () => $@"Expected\n{actual.Stringify()}\n{passed.AsNot()}to deep equal\n{otherValue.Stringify()}", customMessageGenerator ) )); }); return(continuation.More()); }
/// <summary> /// Test the value matched by a prior key match for deep equality /// with another object /// </summary> /// <param name="continuation">Continuation to operate on</param> /// <param name="otherValue">Value to test deep equality against</param> /// <typeparam name="T">Type of the dictionary-sourced value</typeparam> /// <returns></returns> public static IMore <T> To <T>( this IDictionaryValueEqual <T> continuation, object otherValue) { return(continuation.To( otherValue, NULL_STRING)); }
/// <summary> /// Test the value matched by a prior key match for deep equality /// with another object /// </summary> /// <param name="continuation">Continuation to operate on</param> /// <param name="otherValue">Value to test deep equality against</param> /// <param name="customMessage">Custom failure message</param> /// <typeparam name="T">Type of the dictionary-sourced value</typeparam> /// <returns></returns> public static IMore <T> To <T>( this IDictionaryValueEqual <T> continuation, object otherValue, string customMessage) { return(continuation.To( otherValue, () => customMessage)); }