public ArgConstraintTests() { demoMock = MockRepository.Mock <IDemo>(); demoMock.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); testMock = MockRepository.Mock <ITestInterface>(); testMock.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); }
public void MockInterfaceWithGenericMethodWithConstraints_UsingDynamicMock() { ITestInterface mockObj = MockRepository.MockWithRemoting <ITestInterface>(); mockObj.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); mockObj.AddService <IDisposable, SqlConnection>(); mockObj.VerifyAllExpectations(); }
public void Event() { ITestInterface eventMock = MockRepository.Mock <ITestInterface>(); eventMock.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); eventMock.Expect(x => x.AnEvent += Arg <EventHandler <EventArgs> > .Is.Anything); eventMock.AnEvent += handler; eventMock.VerifyExpectations(); }
public void MockInterfaceWithGenericMethodWithConstraints_WhenNotValid_UsingDynamicMock() { ITestInterface mockObj = MockRepository.MockWithRemoting <ITestInterface>(); mockObj.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); mockObj.Expect(x => x.AddService <IDisposable, SqlConnection>()) .Return(mockObj); Assert.Throws <ExpectationViolationException>( () => mockObj.VerifyAllExpectations()); }
public void ListTest() { ITestInterface testMock = MockRepository.Mock <ITestInterface>(); testMock.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); testMock.Expect(x => x.VoidList(Arg <List <string> > .List.Count(Is.GreaterThan(3)))); testMock.Expect(x => x.VoidList(Arg <List <string> > .List.IsIn("hello"))); testMock.VoidList(new List <string>(new string[] { "1", "2", "4", "5" })); testMock.VoidList(new List <string>(new string[] { "1", "3" })); Assert.Throws <ExpectationViolationException>( () => testMock.VerifyExpectations()); }