Exemple #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();
        }
Exemple #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();
        }
		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();
		}
Exemple #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));
        }
		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));
		}
Exemple #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());
        }
Exemple #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());
        }
Exemple #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();
 }
Exemple #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();
        }
Exemple #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);
        }