public void Should_not_start_a_new_saga_if_not_found()
        {
            var context = Scenario.Define <Context>()
                          .WithEndpoint <SagaEndpoint>(b => b.Given(bus =>
            {
                var message = new MessageWithSagaId();

                bus.SetMessageHeader(message, Headers.SagaId, Guid.NewGuid().ToString());
                bus.SetMessageHeader(message, Headers.SagaType, typeof(MySaga).AssemblyQualifiedName);

                bus.SendLocal(message);
            }))
                          .Done(c => c.OtherSagaStarted)
                          .Run();

            Assert.False(context.NotFoundHandlerCalled);
            Assert.True(context.OtherSagaStarted);
            Assert.False(context.MessageHandlerCalled);
            Assert.False(context.TimeoutHandlerCalled);
        }
Exemple #2
0
        public async Task Should_not_start_a_new_saga_if_not_found()
        {
            var context = await Scenario.Define <Context>()
                          .WithEndpoint <SagaEndpoint>(b => b.When(session =>
            {
                var message = new MessageWithSagaId
                {
                    DataId = Guid.NewGuid()
                };
                var options = new SendOptions();

                options.SetHeader(Headers.SagaId, Guid.NewGuid().ToString());
                options.SetHeader(Headers.SagaType, typeof(SagaEndpoint.MessageWithSagaIdSaga).AssemblyQualifiedName);
                options.RouteToThisEndpoint();
                return(session.Send(message, options));
            }))
                          .Done(c => c.Done)
                          .Run();

            Assert.True(context.NotFoundHandlerCalled);
            Assert.False(context.MessageHandlerCalled);
            Assert.False(context.TimeoutHandlerCalled);
        }
Exemple #3
0
 public Task Timeout(MessageWithSagaId state, IMessageHandlerContext context)
 {
     TestContext.TimeoutHandlerCalled = true;
     return(Task.FromResult(0));
 }
Exemple #4
0
 public Task Handle(MessageWithSagaId message, IMessageHandlerContext context)
 {
     TestContext.MessageHandlerCalled = true;
     return(Task.FromResult(0));
 }
 public void Handle(MessageWithSagaId message)
 {
     Context.OtherSagaStarted = true;
 }
 public void Timeout(MessageWithSagaId state)
 {
     Context.TimeoutHandlerCalled = true;
 }
 public void Handle(MessageWithSagaId message)
 {
     Context.MessageHandlerCalled = true;
 }