public void Event() { ITestInterface eventMock = MockRepository.Mock <ITestInterface>(); eventMock.Expect(x => x.AnEvent += Arg <EventHandler <EventArgs> > .Is.Anything); eventMock.AnEvent += handler; eventMock.VerifyExpectations(); }
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 ListTest() { ITestInterface testMock = MockRepository.Mock <ITestInterface>(); 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()); }
public void RefAndOutArgs() { testMock.Expect(x => x.RefOut( Arg <string> .Is.Anything, out Arg <int> .Out(3).Dummy, Arg <string> .Is.Equal("Steinegger"), ref Arg <int> .Ref(Is.Equal(2), 7).Dummy, Arg <string> .Is.NotNull)); int iout = 0; int iref = 2; testMock.RefOut("hallo", out iout, "Steinegger", ref iref, "notnull"); Assert.Equal(3, iout); Assert.Equal(7, iref); testMock.VerifyExpectations(); }