Exemplo n.º 1
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);
 }
Exemplo n.º 2
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));
 }
Exemplo n.º 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);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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));
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
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));
 }