public void RaiseEvent()
        {
            IWithEvents eventHolder = MockRepository.Mock <IWithEvents>();

            eventHolder.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);

            eventHolder.ExpectEvent(x => x.Blah += null)
            .IgnoreArguments();

            eventHolder.Expect(x => x.RaiseEvent())
            .DoInstead(new System.Threading.ThreadStart(delegate()
            {
                eventHolder.Raise(x => x.Blah += null,
                                  new object[] { this, EventArgs.Empty });
            }));

            IEventSubscriber eventSubscriber = MockRepository.Mock <IEventSubscriber>();

            eventSubscriber.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault);
            eventSubscriber.Expect(x => x.Hanlder(this, EventArgs.Empty));

            eventHolder.Blah += new EventHandler(eventSubscriber.Hanlder);
            eventHolder.RaiseEvent();

            eventHolder.VerifyExpectations();
            eventSubscriber.VerifyExpectations();
        }
Exemple #2
0
        public void RaiseEvent()
        {
            IWithEvents eventHolder = (IWithEvents)mocks.StrictMock(typeof(IWithEvents));

            eventHolder.Blah += null;
            LastCall.IgnoreArguments();
            raiser = LastCall.GetEventRaiser();
            eventHolder.RaiseEvent();
            LastCall.Do(new System.Threading.ThreadStart(UseEventRaiser));
            IEventSubscriber eventSubscriber = (IEventSubscriber)mocks.StrictMock(typeof(IEventSubscriber));

            eventSubscriber.Hanlder(this, EventArgs.Empty);

            mocks.ReplayAll();

            eventHolder.Blah += new EventHandler(eventSubscriber.Hanlder);

            eventHolder.RaiseEvent();

            mocks.VerifyAll();
        }