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);
        }
Exemple #2
0
        public void CanProperlyCommitUnitOfWork()
        {
            // arrange
            handlerActivatorForTesting.Handle <string>(str => unitOfWorkManager.RegisterEvent("Handled message: " + str));

            // act
            receiveMessages.Deliver(MessageWith("hello there!"));
            worker.Start();
            Thread.Sleep(500);
            worker.Stop();

            // assert
            unitOfWorkManager.Events
            .ShouldBe(new[]
            {
                "Unit of work created: 1",
                "Handled message: hello there!",
                "1: committed",
                "1: disposed",
            });
        }