public void VerifyingThatAnEventWasFired() { IEventSubscriber subscriber = (IEventSubscriber)mocks.StrictMock(typeof(IEventSubscriber)); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Hanlder(events, EventArgs.Empty); mocks.ReplayAll(); events.RaiseEvent(); mocks.VerifyAll(); }
public void VerifyingThatAnEventWasFired() { IEventSubscriber subscriber = MockRepository.Mock <IEventSubscriber>(); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Expect(x => x.Hanlder(events, EventArgs.Empty)); events.RaiseEvent(); subscriber.VerifyExpectations(); }
public void VerifyingThatAnEventWasFired() { IEventSubscriber subscriber = MockRepository.Mock<IEventSubscriber>(); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Expect(x => x.Hanlder(events, EventArgs.Empty)); events.RaiseEvent(); subscriber.VerifyExpectations(); }
public void VerifyingThatAnEventWasFiredThrowsForDifferentArgument() { IEventSubscriber subscriber = MockRepository.Mock <IEventSubscriber>(); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Expect(x => x.Hanlder(events, new EventArgs())); events.RaiseEvent(); Assert.Throws <ExpectationViolationException>( () => subscriber.VerifyExpectations(true)); }
public void VerifyingThatAnEventWasFiredThrowsForDifferentArgument() { IEventSubscriber subscriber = MockRepository.Mock<IEventSubscriber>(); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Expect(x => x.Hanlder(events, new EventArgs())); events.RaiseEvent(); Assert.Throws<ExpectationViolationException>( () => subscriber.VerifyExpectations(true)); }
public void VerifyingThatAnEventWasFiredThrowsForDifferentArgument() { MockRepository mocks = new MockRepository(); IEventSubscriber subscriber = (IEventSubscriber)mocks.StrictMock(typeof(IEventSubscriber)); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Hanlder(events, new EventArgs()); mocks.ReplayAll(); Assert.Throws <ExpectationViolationException>( "IEventSubscriber.Hanlder(Rhino.Mocks.Tests.FieldsProblem.WithEvents, System.EventArgs); Expected #0, Actual #1.\r\nIEventSubscriber.Hanlder(Rhino.Mocks.Tests.FieldsProblem.WithEvents, System.EventArgs); Expected #1, Actual #0.", () => events.RaiseEvent()); }
public void VerifyingThatAnEventWasFiredThrowsForDifferentArgument() { MockRepository mocks = new MockRepository(); IEventSubscriber subscriber = (IEventSubscriber)mocks.StrictMock(typeof(IEventSubscriber)); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Hanlder(events, new EventArgs()); mocks.ReplayAll(); Assert.Throws<ExpectationViolationException>( "IEventSubscriber.Hanlder(Rhino.Mocks.Tests.FieldsProblem.WithEvents, System.EventArgs); Expected #0, Actual #1.\r\nIEventSubscriber.Hanlder(Rhino.Mocks.Tests.FieldsProblem.WithEvents, System.EventArgs); Expected #1, Actual #0.", () => events.RaiseEvent()); }
public void VerifyingThatAnEventWasFiredThrowsForDifferentArgument() { MockRepository mocks = new MockRepository(); IEventSubscriber subscriber = (IEventSubscriber)mocks.StrictMock(typeof(IEventSubscriber)); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Hanlder(events, new EventArgs()); mocks.ReplayAll(); events.RaiseEvent(); mocks.VerifyAll(); }
public void VerifyingThatAnEventWasFiredThrowsForDifferentArgument() { IEventSubscriber subscriber = (IEventSubscriber)MockRepository.GenerateStrictMock(typeof(IEventSubscriber), null); IWithEvents events = new WithEvents(); // This doesn't create an expectation because no method is called on subscriber!! events.Blah += new EventHandler(subscriber.Hanlder); subscriber.Expect(x => x.Hanlder(events, new EventArgs())); var ex = Assert.Throws<ExpectationViolationException>(() => events.RaiseEvent()); Assert.Equal("IEventSubscriber.Hanlder(Rhino.Mocks.Tests.FieldsProblem.WithEvents, System.EventArgs); Expected #0, Actual #1.\r\nIEventSubscriber.Hanlder(Rhino.Mocks.Tests.FieldsProblem.WithEvents, System.EventArgs); Expected #1, Actual #0.", ex.Message); }