public void CanUseNonRecordReplayModel_Expect() { MockRepository mocks = new MockRepository(); IFoo54 demo = mocks.DynamicMock <IFoo54>(); demo.Expect(x => x.DoSomething()).Return(1).Repeat.Once(); mocks.Replay(demo); Assert.Equal(1, demo.DoSomething()); demo.Expect(x => x.DoSomething()).Return(15).Repeat.Once(); Assert.Equal(15, demo.DoSomething()); mocks.VerifyAll(); }
public void WhenNoExpectationIsSetup_WillReturnDefaultValues() { MockRepository mocks = new MockRepository(); IFoo54 demo = mocks.DynamicMock <IFoo54>(); Assert.Equal(0, demo.DoSomething()); }
public void CanUseNonRecordReplayModel_Stub() { MockRepository mocks = new MockRepository(); IFoo54 demo = mocks.DynamicMock <IFoo54>(); demo.Stub(x => x.DoSomething()).Return(1); mocks.Replay(demo); Assert.Equal(1, demo.DoSomething()); }
public void CanAssertNotCalledOnPropertyAccess() { MockRepository mocks = new MockRepository(); IFoo54 demo = mocks.DynamicMock <IFoo54>(); mocks.Replay(demo); demo.DoSomething(); demo.AssertWasNotCalled(x => x.FooBar); }
public void CanAssertOnMethodCall() { MockRepository mocks = new MockRepository(); IFoo54 demo = mocks.DynamicMock <IFoo54>(); mocks.Replay(demo); demo.DoSomething(); demo.AssertWasCalled(x => x.DoSomething()); }
public void UsingExpectWithoutSettingReturnValueThrows() { MockRepository mocks = new MockRepository(); IFoo54 demo = mocks.DynamicMock <IFoo54>(); demo.Expect(x => x.DoSomething()); mocks.Replay(demo); Assert.Throws <InvalidOperationException>( "Method 'IFoo54.DoSomething();' requires a return value or an exception to throw.", () => Assert.Equal(1, demo.DoSomething())); }