public void use_matching_storage_to_build_the_repository()
        {
            var types = new SagaTypes
            {
                MessageType = GetType(),
                StateType   = typeof(MySagaState)
            };

            var storage1 = MockRepository.GenerateMock <ISagaStorage>();
            var storage2 = MockRepository.GenerateMock <ISagaStorage>();
            var storage3 = MockRepository.GenerateMock <ISagaStorage>();

            var settings = new TransportSettings();

            settings.SagaStorageProviders.Add(storage1);
            settings.SagaStorageProviders.Add(storage2);
            settings.SagaStorageProviders.Add(storage3);

            var def = new ObjectDef();

            storage3.Stub(x => x.RepositoryFor(types))
            .Return(def);

            StatefulSagaConvention.DetermineSagaRepositoryDef(settings, types)
            .ShouldBeTheSameAs(def);
        }
        public void to_saga_types_for_a_handler_call()
        {
            var call  = HandlerCall.For <SimpleSagaHandler>(x => x.Last(null));
            var types = StatefulSagaConvention.ToSagaTypes(call);

            types.HandlerType.ShouldEqual(typeof(SimpleSagaHandler));
            types.MessageType.ShouldEqual(typeof(SagaMessageThree));
            types.StateType.ShouldEqual(typeof(MySagaState));
        }
 public void unable_to_determine_a_saga_repository_blows_up()
 {
     Exception <SagaRepositoryUnresolvableException> .ShouldBeThrownBy(() => {
         StatefulSagaConvention.DetermineSagaRepositoryDef(new TransportSettings(), new SagaTypes
         {
             MessageType = GetType(),
             StateType   = GetType()
         });
     });
 }
        public void is_saga_chain_is_true_for_handler_chain_with_a_saga_handler()
        {
            var call = HandlerCall.For<SimpleSagaHandler>(x => x.Last(null));

            var chain = new HandlerChain();
            chain.AddToEnd(call);

            StatefulSagaConvention.IsSagaChain(chain)
                .ShouldBeTrue();
        }
        public void is_saga_chain_is_false_for_handler_chain_with_no_saga_handlers()
        {
            var call = HandlerCall.For<SimpleHandler<OneMessage>>(x => x.Handle(null));

            var chain = new HandlerChain();
            chain.AddToEnd(call);

            StatefulSagaConvention.IsSagaChain(chain)
                .ShouldBeFalse();
        }
        public void no_registered_storage_and_matches_the_idiom_so_use_in_memory_cache()
        {
            var types = new SagaTypes
            {
                MessageType = typeof(SagaMessageOne),
                StateType   = typeof(MySagaState)
            };

            StatefulSagaConvention.DetermineSagaRepositoryDef(new TransportSettings(), types)
            .Type.ShouldEqual(typeof(InMemorySagaRepository <MySagaState, SagaMessageOne>));
        }
        public void is_saga_handler_positive()
        {
            StatefulSagaConvention.IsSagaHandler(HandlerCall.For <SimpleSagaHandler>(x => x.Start(null)))
            .ShouldBeTrue();

            StatefulSagaConvention.IsSagaHandler(HandlerCall.For <SimpleSagaHandler>(x => x.Second(null)))
            .ShouldBeTrue();

            StatefulSagaConvention.IsSagaHandler(HandlerCall.For <SimpleSagaHandler>(x => x.Last(null)))
            .ShouldBeTrue();
        }
Exemplo n.º 8
0
 /// <summary>
 /// Find Handlers suffixed with 'Saga' that have public properties of 'State' and 'IsCompleted'
 /// </summary>
 public void IncludeClassesMatchingSagaConvention()
 {
     _description.WriteLine("Public classes suffixed with Saga that have public properties of 'State' and 'IsCompleted'");
     IncludeTypes(x => StatefulSagaConvention.IsSagaHandler(x));
 }
 public void is_saga_chain_is_false_for_regular_behavior_chain()
 {
     StatefulSagaConvention.IsSagaChain(new BehaviorChain())
     .ShouldBeFalse();
 }
 public void is_saga_handler_negative()
 {
     StatefulSagaConvention.IsSagaHandler(HandlerCall.For <SimpleHandler <OneMessage> >(x => x.Handle(null)))
     .ShouldBeFalse();
 }