[Test] public void StubbedMethodsCanBeCalledByOtherMethodsWithinObject() { DynamicMock mock = new DynamicMock(typeof(SameClass)); mock.Ignore("A"); mock.Ignore("c"); SameClass sc = (SameClass)mock.MockInstance; mock.SetupResult("b", "hello"); Assertion.AssertEquals("hello", sc.A()); }
[Test] public void CanSetStubsAndExpectationsOnMethodsInTheSameClass() { DynamicMock mock = new DynamicMock(typeof(SameClass)); mock.Ignore("A"); SameClass sc = (SameClass)mock.MockInstance; mock.ExpectAndReturn("c", true); mock.SetupResult("b", "hello"); AssertEquals("Should have overriden B()", "hello", sc.A()); mock.Verify(); }
public void ReuseGeneratedAssembly() { DynamicMock mock = new DynamicMock(typeof(SameClass)); mock.Ignore("A"); mock.Ignore("c"); SameClass sc = (SameClass)mock.MockInstance; mock.SetupResult("b", "hello"); Assertion.AssertEquals("hello", sc.A()); mock = new DynamicMock(typeof(SameClass)); mock.Ignore("A"); sc = (SameClass)mock.MockInstance; mock.ExpectAndReturn("c", true); mock.SetupResult("b", "hello"); AssertEquals("Should have overriden B()", "hello", sc.A()); mock.Verify(); }