Exemplo n.º 1
0
        public void saga_types_gives_an_empty_guid_func_if_correlation_id_does_not_exist()
        {
            var types = new SagaTypes
            {
                MessageType = GetType()
            };

            var func = types.ToCorrelationIdFunc().ShouldBeOfType<Func<SagaTypesTester, Guid>>();
            func(this).ShouldBe(Guid.Empty);
        }
Exemplo n.º 2
0
        public void saga_types_gives_an_empty_guid_func_if_correlation_id_does_not_exist()
        {
            var types = new SagaTypes
            {
                MessageType = GetType()
            };

            var func = types.ToCorrelationIdFunc().ShouldBeOfType <Func <SagaTypesTester, Guid> >();

            func(this).ShouldBe(Guid.Empty);
        }
        public ObjectDef RepositoryFor(SagaTypes sagaTypes)
        {
            if (sagaTypes.StateType.GetProperty(SagaTypes.Id) == null)
            {
                return null;
            }

            var objectDef = new ObjectDef(typeof (InMemorySagaRepository<,>), sagaTypes.StateType, sagaTypes.MessageType);

            objectDef.DependencyByValue(typeof(Func<,>).MakeGenericType(sagaTypes.StateType, typeof(Guid)), sagaTypes.ToSagaIdFunc());
            objectDef.DependencyByValue(typeof(Func<,>).MakeGenericType(sagaTypes.MessageType, typeof(Guid)), sagaTypes.ToCorrelationIdFunc());

            return objectDef;
        }
Exemplo n.º 4
0
        public Instance RepositoryFor(SagaTypes sagaTypes)
        {
            if (sagaTypes.StateType.GetProperty(SagaTypes.Id) == null)
            {
                return null;
            }

            var instance = new ConfiguredInstance(typeof (InMemorySagaRepository<,>), sagaTypes.StateType, sagaTypes.MessageType);
            instance.Dependencies.Add(typeof(Func<,>).MakeGenericType(sagaTypes.StateType, typeof(Guid)), sagaTypes.ToSagaIdFunc());
            instance.Dependencies.Add(typeof(Func<,>).MakeGenericType(sagaTypes.MessageType, typeof(Guid)), sagaTypes.ToCorrelationIdFunc());


            return instance;
        }
Exemplo n.º 5
0
        public void saga_types_being_able_to_gimme_a_correlation_id_getter_from_the_message_type()
        {
            var types = new SagaTypes
            {
                MessageType = typeof(SagaMessageOne)
            };

            var func = types.ToCorrelationIdFunc().ShouldBeOfType <Func <SagaMessageOne, Guid> >();

            var message = new SagaMessageOne
            {
                CorrelationId = Guid.NewGuid()
            };

            func(message).ShouldBe(message.CorrelationId);
        }
Exemplo n.º 6
0
        public void saga_types_being_able_to_gimme_a_correlation_id_getter_from_the_message_type()
        {
            var types = new SagaTypes
            {
                MessageType = typeof(SagaMessageOne)
            };

            var func = types.ToCorrelationIdFunc().ShouldBeOfType<Func<SagaMessageOne, Guid>>();

            var message = new SagaMessageOne
            {
                CorrelationId = Guid.NewGuid()
            };

            func(message).ShouldBe(message.CorrelationId);
        }
        public static InMemorySagaRepository <TState, TMessage> Create()
        {
            var types = new SagaTypes
            {
                StateType   = typeof(TState),
                MessageType = typeof(TMessage)
            };

            return(new InMemorySagaRepository <TState, TMessage>((Func <TMessage, Guid>)types.ToCorrelationIdFunc(), (Func <TState, Guid>)types.ToSagaIdFunc(), new SagaStateCacheFactory()));
        }
Exemplo n.º 8
0
        public Instance RepositoryFor(SagaTypes sagaTypes)
        {
            if (sagaTypes.StateType.GetProperty(SagaTypes.Id) == null)
            {
                return(null);
            }

            var instance = new ConfiguredInstance(typeof(InMemorySagaRepository <,>), sagaTypes.StateType, sagaTypes.MessageType);

            instance.Dependencies.Add(typeof(Func <,>).MakeGenericType(sagaTypes.StateType, typeof(Guid)), sagaTypes.ToSagaIdFunc());
            instance.Dependencies.Add(typeof(Func <,>).MakeGenericType(sagaTypes.MessageType, typeof(Guid)), sagaTypes.ToCorrelationIdFunc());


            return(instance);
        }
        public ObjectDef RepositoryFor(SagaTypes sagaTypes)
        {
            if (sagaTypes.StateType.GetProperty(SagaTypes.Id) == null)
            {
                return(null);
            }

            var objectDef = new ObjectDef(typeof(InMemorySagaRepository <,>), sagaTypes.StateType, sagaTypes.MessageType);

            objectDef.DependencyByValue(typeof(Func <,>).MakeGenericType(sagaTypes.StateType, typeof(Guid)), sagaTypes.ToSagaIdFunc());
            objectDef.DependencyByValue(typeof(Func <,>).MakeGenericType(sagaTypes.MessageType, typeof(Guid)), sagaTypes.ToCorrelationIdFunc());

            return(objectDef);
        }