コード例 #1
0
        public void ArgsEqualWhenArgsMatch()
        {
            IExpectation expectation = new ArgsEqualExpectation(new FakeInvocation(method), new object[] { 1, "43", 5.2f }, new Range(1, 1));

            object[] args = new object[] { 1, "43", 5.2f };
            Assert.True(expectation.IsExpected(args));
        }
コード例 #2
0
        public void ArgsEqualWithDifferentNumberOfParameters()
        {
            IExpectation expectation = new ArgsEqualExpectation(new FakeInvocation(method), new object[] { 1, "43", 5.2f }, new Range(1, 1));

            object[] args = new object[] { 1, "43" };
            Assert.False(expectation.IsExpected(args));
            Assert.Equal(String.Format("IDemo.VoidThreeArgs(1, \"43\", {0:N1});", 5.2), expectation.ErrorMessage);
        }
コード例 #3
0
        public void ArgsEqualWhenArgsMismatch()
        {
            IExpectation expectation = new ArgsEqualExpectation(new FakeInvocation(method), new object[] { 1, "43", 5.2f }, new Range(1, 1));

            object[] args = new object[] { 1, "43", 6.4f };
            Assert.False(expectation.IsExpected(args));
            Assert.Equal(String.Format("IDemo.VoidThreeArgs(1, \"43\", {0:N1});", 5.2), expectation.ErrorMessage);
        }
コード例 #4
0
        public void ArgsEqualWhenValueTypeArrayArgsMatch()
        {
            MethodInfo   method      = typeof(IDemo).GetMethod("VoidValueTypeArrayArgs");
            IExpectation expectation = new ArgsEqualExpectation(new FakeInvocation(method), new object[] { new ushort[] { 123, 456 } }, new Range(1, 1));

            object[] args = new object[] { new ushort[] { 123 } };
            Assert.False(expectation.IsExpected(args));
            Assert.Equal("IDemo.VoidValueTypeArrayArgs([123, 456]);", expectation.ErrorMessage);
        }
コード例 #5
0
        public void ArgsEqualWithArrayReferenceEqual()
        {
            object[] arr = new object[3] {
                "1", 2, 5.2f
            };
            IExpectation expectation = new ArgsEqualExpectation(new FakeInvocation(method), new object[] { 1, arr }, new Range(1, 1));

            object[] args = new object[] { 1, arr };
            Assert.True(expectation.IsExpected(args));
        }
コード例 #6
0
        public void ArgsEqualWithStringArray()
        {
            MethodInfo method = typeof(IDemo).GetMethod("VoidThreeStringArgs");

            string[] str1 = new string[] { "", "1", "1234" },
            str2 = new string[] { "1", "1234", "54321" };
            IExpectation expectation = new ArgsEqualExpectation(new FakeInvocation(method), str1, new Range(1, 1));

            Assert.False(expectation.IsExpected(str2));
            Assert.Equal("IDemo.VoidThreeStringArgs(\"\", \"1\", \"1234\");", expectation.ErrorMessage);
        }
コード例 #7
0
        public void ArgsEqualWithArrayContentEqual()
        {
            object[] arr1 = new object[3] {
                "1", 2, 4.5f
            },
            arr2 = new object[3] {
                "1", 2, 4.5f
            };
            IExpectation expectation = new ArgsEqualExpectation(new FakeInvocation(method), new object[] { 1, arr2 }, new Range(1, 1));

            object[] args = new object[] { 1, arr1 };
            Assert.True(expectation.IsExpected(args));
        }
コード例 #8
0
        public void ArgsEqualWithArrayContentLengthDifferent()
        {
            object[] arr1 = new object[3] {
                "1", 2, 4.5f
            },
            arr2 = new object[2] {
                "1", 5
            };
            IExpectation expectation = new ArgsEqualExpectation(new FakeInvocation(method), new object[] { 1, arr1 }, new Range(1, 1));

            object[] args = new object[] { 1, arr2 };
            Assert.False(expectation.IsExpected(args));
            Assert.Equal(String.Format("IDemo.VoidThreeArgs(1, [\"1\", 2, {0:N1}], missing parameter);", 4.5), expectation.ErrorMessage);
        }
コード例 #9
0
 public void AnyArgsExpectationReturnTrueForDifferentArgs()
 {
     Assert.False(equal.IsExpected(new object[0]));
     Assert.True(any.IsExpected(new object[0]));
 }