Ejemplo n.º 1
0
        public void IgnoresAutoCorrelationWhenCorrelationIsExplicitlySetUp(bool abandonReply)
        {
            // arrange
            var anotherSaga = new AnotherSaga(sagaBus, abandonReply);

            sagaHandlerActivator.UseHandler(anotherSaga);

            serviceHandlerActivator.Handle <RequestWithCorrelationId>(req => serviceBus.Reply(new ReplyWithCorrelationId {
                Correlationid = req.Correlationid
            }));

            // act
            initiatorBus.Send(new InitiateRequestReply());
            Thread.Sleep(3.Seconds());

            // assert
            sagaPersister.Count().ShouldBe(1);
            var sagaData = sagaPersister.Single();

            sagaData.ShouldBeTypeOf <SomeSagaData>();
            ((SomeSagaData)sagaData).GotTheReply.ShouldBe(!abandonReply);
        }
        public void ShouldWork()
        {
            var store = new EmbeddableDocumentStore
            {
                RunInMemory = true
            };

            store.Initialize();

            var activator = new HandlerActivatorForTesting();
            var checker   = new CheckCallsMade();
            var bus       = CreateBus(Queue, activator, new InMemorySubscriptionStorage(), new RavenDbSagaPersister(store), "errors").Start(1);

            activator.UseHandler(() => new TheSaga(bus, checker));
            bus.Send(new TheFirstMessage());

            Thread.Sleep(5000);
            Assert.IsTrue(checker.First, "First should be called");
            Assert.IsTrue(checker.Second, "Second should be called");
            Assert.IsTrue(checker.Third, "Third should be called");
        }
Ejemplo n.º 3
0
        public void ThrowsIfTwoSagaHandlersArePresentInHandlerPipeline()
        {
            // arrange
            activator.UseHandler(new FirstSaga());
            activator.UseHandler(new SecondSaga());
            var messageThatCanBeHandledByBothSagas = new SomeMessage();

            // act
            var exception =
                Should.Throw <MultipleSagaHandlersFoundException>(
                    async() => await dispatcher.Dispatch(messageThatCanBeHandledByBothSagas));

            // assert
            exception.Message.ShouldContain("FirstSaga");
            exception.Message.ShouldContain("SecondSaga");
            exception.Message.ShouldContain("SomeMessage");
        }