public void MatcherDescriptionMustBeCorrect() { var expected = ExpectMatcherDescription(); var description = new StringDescription(); _matcher.DescribeTo(description); var actual = description.ToString(); Xunit.Assert.Equal(expected, actual); }
public static void That <T>(String reason, Func <T> func, IMatcher <T> matcher) { T actual = WaitAndGetActualValue(func, matcher, _timeout, _delay); if (!matcher.Matches(actual)) { StringDescription stringDescription1 = new StringDescription(); matcher.DescribeTo(stringDescription1); StringDescription stringDescription2 = new StringDescription(); matcher.DescribeMismatch(actual, stringDescription2); throw new MatchException(stringDescription1.ToString(), stringDescription2.ToString(), reason); } }
public static void That <T>(T actual, IMatcher <T> matcher) { if (matcher.Matches(actual)) { return; } var description = new StringDescription(); matcher.DescribeTo(description); var mismatchDescription = new StringDescription(); matcher.DescribeMismatch(actual, mismatchDescription); throw new MatchException(description.ToString(), mismatchDescription.ToString(), null); }
///<summary> /// Asserts that an item satisfies the condition specified by matcher. ///</summary> ///<param name="item">The item to test.</param> ///<param name="matcher">A <see cref="IMatcher{T}">matcher</see>.</param> ///<param name="messageFormat">The custom assertion message format, or null if none.</param> ///<param name="messageArgs">The custom assertion message arguments, or null if none.</param> ///<typeparam name="T">The static type accepted by the matcher.</typeparam> public static void That <T>(T item, IMatcher <T> matcher, string messageFormat, params object[] messageArgs) { AssertionHelper.Verify(() => { if (matcher.Matches(item)) { return(null); } var description = new StringDescription(); var mismatchDescription = new StringDescription(); matcher.DescribeTo(description); matcher.DescribeMismatch(item, mismatchDescription); return(new AssertionFailureBuilder("Expected " + description) .SetMessage(messageFormat, messageArgs) .AddLabeledValue("Expected", description.ToString()) .AddLabeledValue("But", mismatchDescription.ToString()) .ToAssertionFailure()); }); }
public void DescribeTo(IDescription description) { _createdMatcher.DescribeTo(description); }
public override void DescribeTo(IDescription description) { _decoratedMatcher.DescribeTo(description); }
public override void DescribeTo(IDescription description) { _toDecorate.DescribeTo(description); }
public void DescribeTo(IDescription description) { _innerMatcher.DescribeTo(description); }