Beispiel #1
0
        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();

            string expectedMessage="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.";
            ExpectationViolationException ex = Assert.Throws<ExpectationViolationException>(
                () => events.RaiseEvent());
            Assert.Equal(expectedMessage, ex.Message);
        }
Beispiel #2
0
 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();
 }