Exemple #1
0
        public void MessageContextIsEstablishedWhenHandlerActivatorIsCalled()
        {
            // arrange
            worker.Start();
            var callWasIntercepted = false;

            activateHandlers.Stub(a => a.GetHandlerInstancesFor <string>())
            .WhenCalled(mi =>
            {
                MessageContext.HasCurrent.ShouldBe(true);
                callWasIntercepted = true;
            })
            .Return(new List <IHandleMessages <string> > {
                this
            });

            var message = new Message {
                Messages = new object[] { "w00t!" }
            };

            // act
            receiveMessages.Deliver(message);
            Thread.Sleep(300);

            // assert
            callWasIntercepted.ShouldBe(true);
        }