示例#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);
        }