public void VerifyingThatEventWasAttached()
		{
            IWithEvent events = MockRepository.Mock<IWithEvent>();

            events.ExpectEvent(x => x.Load += null)
                .IgnoreArguments();
			
			EventConsumer consumerMock = new EventConsumer(events);
			
            //Next line invokes Load event.
            events.Raise(x => x.Load += null, EventArgs.Empty);
			
			Assert.True(consumerMock.OnLoadCalled);
            events.VerifyAllExpectations();
		}
Example #2
0
		public void VerifyingThatEventWasAttached()
		{
			MockRepository mocks = new MockRepository();
			IWithEvent events = (IWithEvent)mocks.StrictMock(typeof(IWithEvent));
			events.Load += null; //ugly syntax, I know, but the only way to get this to work
			IEventRaiser raiser = LastCall.IgnoreArguments().GetEventRaiser();
			mocks.ReplayAll();

			EventConsumer consumerMock = new EventConsumer(events);
			//Next line invokes Load event.
			raiser.Raise(this, EventArgs.Empty);
			mocks.VerifyAll();

			Assert.True(consumerMock.OnLoadCalled);
		}
Example #3
0
        public void VerifyingThatEventWasAttached()
        {
            IWithEvent events = MockRepository.Mock <IWithEvent>();

            events.ExpectEvent(x => x.Load += null)
            .IgnoreArguments();

            EventConsumer consumerMock = new EventConsumer(events);

            //Next line invokes Load event.
            events.Raise(x => x.Load += null, EventArgs.Empty);

            Assert.True(consumerMock.OnLoadCalled);
            events.VerifyAllExpectations();
        }
        public void VerifyingThatEventWasAttached()
        {
            MockRepository mocks = new MockRepository();
            IWithEvent events = (IWithEvent)mocks.StrictMock(typeof(IWithEvent));
            events.Load += null; //ugly syntax, I know, but the only way to get this to work
            IEventRaiser raiser = LastCall.IgnoreArguments().GetEventRaiser();
            mocks.ReplayAll();

            EventConsumer consumerMock = new EventConsumer(events);
            //Next line invokes Load event.
            raiser.Raise(this, EventArgs.Empty);
            mocks.VerifyAll();

            Assert.True(consumerMock.OnLoadCalled);
        }
        public void VerifyingThatEventWasAttached()
        {
            IWithEvent events = (IWithEvent)MockRepository.GenerateStrictMock(typeof(IWithEvent), null, null);
            IEventRaiser raiser = events.Expect(x => x.Load += null).IgnoreArguments().GetEventRaiser();

            EventConsumer consumerMock = new EventConsumer(events);
            //Next line invokes Load event.
            raiser.Raise(this, EventArgs.Empty);
            events.VerifyAllExpectations();

            Assert.True(consumerMock.OnLoadCalled);
        }