Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
        public void DoesNotMatchAnObjectThatIsNotAnInvocation()
        {
            Matcher matcher = new ArgumentsMatcher();

            Assert.IsFalse(matcher.Matches("not an invocation"));
        }
Exemplo n.º 7
0
        public void MatchesInvocationWithSameNumberOfArgumentsAsMatcherHasValueMatchersAndValueMatchersMatch()
        {
            Matcher matcher = new ArgumentsMatcher(Is.EqualTo(arg1Value), Is.EqualTo(arg2Value));

            Assert.IsTrue(matcher.Matches(InvocationWithArguments(arg1Value, arg2Value)));
        }