public void DoesNotMatchInvocationWithDifferentNumberOfArguments() { Matcher matcher = new ArgumentsMatcher(Is.Anything, Is.Anything); Assert.IsFalse(matcher.Matches(InvocationWithArguments(1)), "fewer arguments"); Assert.IsFalse(matcher.Matches(InvocationWithArguments(1, 2, 3)), "more arguments"); }
public void DoesNotMatchIfValueMatchersDoNotMatchArgumentValues() { Matcher matcher = new ArgumentsMatcher(Is.EqualTo(arg1Value), Is.EqualTo(arg2Value)); Assert.IsFalse(matcher.Matches(InvocationWithArguments("other object", arg2Value)), "different first arg"); Assert.IsFalse(matcher.Matches(InvocationWithArguments(arg1Value, "other object")), "different second arg"); }
public void DoesNotMatchAndDoesNotThrowExceptionIfValueSpecifiedForOutputParameter() { Matcher matcher = new ArgumentsMatcher(Is.EqualTo(arg1Value), Is.EqualTo(arg2Value)); Invocation invocation = new Invocation( new NamedObject("receiver"), new MethodInfoStub("method", new ParameterInfoStub("in", ParameterAttributes.In), new ParameterInfoStub("out", ParameterAttributes.Out)), new[] { arg1Value, null }); Assert.IsFalse(matcher.Matches(invocation)); }
public void MatchesOutputParametersWithSpecialMatcherClass() { Matcher matcher = new ArgumentsMatcher(Is.EqualTo(arg1Value), Is.Out); Invocation invocation = new Invocation( new NamedObject("receiver"), new MethodInfoStub("method", new ParameterInfoStub("in", ParameterAttributes.In), new ParameterInfoStub("out", ParameterAttributes.Out)), new[] { arg1Value, null }); Assert.IsTrue(matcher.Matches(invocation)); }
public bool MatchesIgnoringIsActive(Invocation invocation) { if (Receiver != invocation.Receiver) { return(false); } if (!MethodMatcher.Matches(invocation.Method)) { return(false); } if (!ArgumentsMatcher.Matches(invocation)) { return(false); } if (!ExtraMatchersMatch(invocation)) { return(false); } return(true); }
public void DoesNotMatchAnObjectThatIsNotAnInvocation() { Matcher matcher = new ArgumentsMatcher(); Assert.IsFalse(matcher.Matches("not an invocation")); }
public void MatchesInvocationWithSameNumberOfArgumentsAsMatcherHasValueMatchersAndValueMatchersMatch() { Matcher matcher = new ArgumentsMatcher(Is.EqualTo(arg1Value), Is.EqualTo(arg2Value)); Assert.IsTrue(matcher.Matches(InvocationWithArguments(arg1Value, arg2Value))); }