public bool Matches(ITestActualEvaluation <T> actualFactory) { var myParent = _parent; return(_real.Matches( Actual = TestActual.Of(() => myParent._accessor(actualFactory.Value)) )); }
public bool Matches(ITestActualEvaluation <TFrom> actualFactory) { var real = TestMatcherName.FromType(_real.GetType()); Func <T> thunk = () => { try { var actual = actualFactory.Value; return((T)(object)actual); } catch (InvalidCastException e) { throw SpecFailure.CastRequiredByMatcherFailure(e, real); } }; return(_real.Matches(TestActual.Of(thunk))); }
public bool Matches(ITestActualEvaluation <IEnumerable> actualFactory) { // When the matcher can already handle the input, no need to apply // adapter logic if (_real is ITestMatcher <IEnumerable> fast) { return(fast.Matches(actualFactory)); } var real = TestMatcherName.FromType(_real.GetType()); Func <IEnumerable <object> > thunk = () => ( actualFactory.Value.Cast <object>() ); return(_real.Matches(TestActual.Of(thunk))); }
public static Tally New <T>( IEnumerable <T> items, ITestMatcher <T> matcher, Predicate <Tally> stop, TestFailure predicateFailure = null) { if (stop == null) { stop = _ => false; } if (predicateFailure == null) { predicateFailure = TestMatcherLocalizer.FailurePredicate(matcher); } var result = new Tally(); result.Indexes = new List <int>(); int index = 0; foreach (var item in items) { if (stop(result)) { result.Stopped = true; break; } var matches = matcher.Matches(TestActual.Value(item)); if (matches) { result.Successes++; } else { result.Failures++; result.Indexes.Add(index); result.AFailure = predicateFailure; } index++; } return(result); }
public override TestFailure Should(ITestMatcher <T> matcher) { var actual = TestActual.Of(_thunk); if (_negated) { matcher = Matchers.Not(matcher); } if (matcher.Matches(actual)) { return(null); } var result = TestMatcherLocalizer.Failure(matcher, actual.Value) .UpdateGiven(_given) .UpdateBehavior(_behavior); if (matcher is ITestMatcher <Unit> m) { result.UpdateActual(DisplayActual.Exception(actual.Exception)); } return(result); }
internal static bool Matches <T>(this ITestMatcher <T> self, Func <T> actualFactory) { return(self.Matches(new TestActual <T>(actualFactory))); }
public static bool Matches(this ITestMatcher self, Action testCode) { return(self.Matches( TestActual.Of(Unit.Thunk(testCode)) )); }
public bool Matches(ITestActualEvaluation <T> actualFactory) { return(!_matcher.Matches(actualFactory)); }
public bool Matches(ITestActualEvaluation <T> actualFactory) { return(_real.Matches( Actual = TestActual.Value(actualFactory.Exception) )); }