コード例 #1
0
        public void DoesNotMatchAndDoesNotThrowExceptionIfValueSpecifiedForOutputParameter()
        {
            Matcher matcher = new ArgumentsMatcher(Is.Same(arg1Value), Is.Same(arg2Value));

            var 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));
        }
コード例 #2
0
        public void DoesNotMatchIfValueMatchersDoNotMatchArgumentValues()
        {
            Matcher matcher = new ArgumentsMatcher(Is.Same(arg1Value), Is.Same(arg2Value));

            Assert.IsFalse(matcher.Matches(InvocationWithArguments("other object", arg2Value)),
                           "different first arg");
            Assert.IsFalse(matcher.Matches(InvocationWithArguments(arg1Value, "other object")),
                           "different second arg");
        }
コード例 #3
0
 public void DoesNotMatchAnObjectThatIsNotAnInvocation()
 {
     Matcher matcher = new ArgumentsMatcher();
     Assert.IsFalse(matcher.Matches("not an invocation"));
 }
コード例 #4
0
        public void ShowsOutputParametersInDescription()
        {
            Matcher matcher = new ArgumentsMatcher(new AlwaysMatcher(true, "arg1"), Is.Out);

            AssertDescription.IsEqual(matcher, "(arg1, out)");
        }
コード例 #5
0
        public void MatchesOutputParametersWithSpecialMatcherClass()
        {
            Matcher matcher = new ArgumentsMatcher(Is.Same(arg1Value), Is.Out);

            var 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));
        }
コード例 #6
0
        public void MatchesInvocationWithSameNumberOfArgumentsAsMatcherHasValueMatchersAndValueMatchersMatch()
        {
            Matcher matcher = new ArgumentsMatcher(Is.Same(arg1Value), Is.Same(arg2Value));

            Assert.IsTrue(matcher.Matches(InvocationWithArguments(arg1Value, arg2Value)));
        }
コード例 #7
0
        public void FormatsDescriptionToLookSimilarToAnArgumentList()
        {
            Matcher matcher = new ArgumentsMatcher(
                new AlwaysMatcher(true, "arg1-description"),
                new AlwaysMatcher(true, "arg2-description"));

            AssertDescription.IsEqual(matcher, "(arg1-description, arg2-description)");
        }
コード例 #8
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");
        }