[Test][ExpectedException(typeof(VerifyException))] public void ExpectationWillFailIfValueDoesntMatchMockInstance() { DynamicMock m1 = new DynamicMock(typeof(Thingy)); Thingy thingy = (Thingy)m1.MockInstance; Mock m2 = new Mock("x"); m2.Expect("y", thingy); m2.Invoke("y", new object[] { "something else" }, new string[] { "System.String" }); }
[Test] public void MockInstanceCanBeUsedAsValueInAnExpectation() { DynamicMock mockThingy = new DynamicMock(typeof(Thingy)); Thingy thingy = (Thingy)mockThingy.MockInstance; Mock m2 = new Mock("x"); m2.Expect("y", thingy); m2.Invoke("y", new object[] { thingy }, new string[] { "NMock.DynamicMockTest.Thingy" }); m2.Verify(); }
[Test] [ExpectedException(typeof(VerifyException))] public void ExpectationWillFailIfValueDoesntMatchMockInstance() { DynamicMock m1 = new DynamicMock(typeof(Thingy)); Thingy thingy = (Thingy)m1.MockInstance; Mock m2 = new Mock("x"); m2.Expect("y", thingy); m2.Invoke("y", new object[] { "something else" }, new string[] { "System.String" }); }
[Test] public void ExpectAndCallAVoidMethod() { mock.Expect("myMethod"); mock.Invoke("myMethod"); mock.Verify(); }