public void MockObjectDelegateWithNoParams() { ObjectDelegateWithNoParams d = MockRepository.Mock <ObjectDelegateWithNoParams>(); d.Expect(x => x()) .Return("abc"); d.Expect(x => x()) .Return("def"); Assert.Equal("abc", d()); Assert.Equal("def", d()); Assert.Null(d()); Assert.Throws <ExpectationViolationException>( () => d.VerifyExpectations(true)); }
public void CallingMockedDelegatesWithoutOn() { ObjectDelegateWithNoParams d1 = MockRepository.Mock <ObjectDelegateWithNoParams>(); d1.Expect(x => x()) .Return(1); Assert.Equal(1, d1()); }
public void CallingMockedDelegatesWithoutOn() { ObjectDelegateWithNoParams d1 = MockRepository.Mock <ObjectDelegateWithNoParams>(); d1.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); d1.Expect(x => x()) .Return(1); Assert.Equal(1, d1()); }
public void MockTwoDelegatesWithTheSameName() { ObjectDelegateWithNoParams d1 = MockRepository.Mock <ObjectDelegateWithNoParams>(); Tests.ObjectDelegateWithNoParams d2 = MockRepository.Mock <Tests.ObjectDelegateWithNoParams>(); d1.Expect(x => x()) .Return(1); d2.Expect(x => x()) .Return(2); Assert.Equal(1, d1()); Assert.Equal(2, d2()); d1.VerifyAllExpectations(); d2.VerifyAllExpectations(); }
public void MockTwoDelegatesWithTheSameName() { ObjectDelegateWithNoParams d1 = MockRepository.Mock <ObjectDelegateWithNoParams>(); d1.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); Tests.ObjectDelegateWithNoParams d2 = MockRepository.Mock <Tests.ObjectDelegateWithNoParams>(); d2.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); d1.Expect(x => x()) .Return(1); d2.Expect(x => x()) .Return(2); Assert.Equal(1, d1()); Assert.Equal(2, d2()); d1.VerifyAllExpectations(); d2.VerifyAllExpectations(); }