Пример #1
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();
        }
Пример #2
0
        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();
        }
Пример #3
0
		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();
		}
Пример #4
0
        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));
        }
Пример #5
0
		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));
		}
Пример #6
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();

            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());
        }
Пример #7
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();

            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());
        }
Пример #8
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();
 }
Пример #9
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();
            events.RaiseEvent();
            mocks.VerifyAll();
        }
Пример #10
0
        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);
        }