public override bool Perform(Invocation invocation) { if (Count == 0) { return(false); } //you would think it would be "if (CurrentExpectation.HasBeenMet)" but "atleast" matchers will have been met //when they can consume more, so increment after a match check //if (CurrentExpectation.HasBeenMet) if (!CurrentExpectation.Matches(invocation) && !invocation.MockObject.IgnoreUnexpectedInvocations) { current++; } //now if this one doesn't match then this is unexpected if (CurrentExpectation.Matches(invocation)) { var result = CurrentExpectation.Perform(invocation); //this helps for adding breakpoints and troubleshooting when returning false if (result) { return(true); } else { return(false); } } return(false); }
/// <summary> /// Checks whether stored expectations matches the specified invocation. /// </summary> /// <param name="invocation">The invocation to check.</param> /// <returns>Returns whether one of the stored expectations has met the specified invocation.</returns> public override bool Matches(Invocation invocation) { if (CurrentExpectation == null) { return(false); } if (Count == 0) { return(false); } return(CurrentExpectation.Matches(invocation) || (CurrentExpectation.HasBeenMet && NextExpectationMatches(invocation))); //look ahead at the next if the current is an "atleast" matcher }