コード例 #1
0
 public InMemorySagaConsumeContext(ConsumeContext <TMessage> context, SagaInstance <TSaga>
                                   instance, IndexedSagaDictionary <TSaga> sagas)
     : base(context)
 {
     _sagas    = sagas;
     _instance = instance;
 }
コード例 #2
0
        public ISagaInstance <CustomRoutesSoftwareProgrammingSaga, SoftwareProgrammingSagaData> Create(SleptWellEvent message)
        {
            var saga = new CustomRoutesSoftwareProgrammingSaga();
            var data = new SagaDataAggregate <SoftwareProgrammingSagaData>(message.SofaId,
                                                                           new SoftwareProgrammingSagaData(saga.Sleeping.Name));

            return(SagaInstance.New(saga, data));
        }
コード例 #3
0
        public ISagaInstance <CustomRoutesSoftwareProgrammingSaga, SoftwareProgrammingSagaData> Create(GotTiredEvent message)
        {
            var saga = new CustomRoutesSoftwareProgrammingSaga();
            var data = new SagaDataAggregate <SoftwareProgrammingSagaData>(message.PersonId,
                                                                           new SoftwareProgrammingSagaData(saga.Coding.Name));

            return(SagaInstance.New(saga, data));
        }
コード例 #4
0
        public Given_AutomatonymousSaga(Func <SoftwareProgrammingSaga, State> initialState)
        {
            var sagaData = new SoftwareProgrammingSagaData(initialState(SagaMachine).Name);

            SagaDataAggregate = new SagaDataAggregate <SoftwareProgrammingSagaData>(Guid.NewGuid(),
                                                                                    sagaData);
            SagaInstance = new SagaInstance <SoftwareProgrammingSaga, SoftwareProgrammingSagaData>(SagaMachine, SagaDataAggregate);
        }
コード例 #5
0
        public void Given_saga_when_publishing_known_message_without_saga_data(bool sagaHasId, bool sagaHasData)
        {
            var softwareProgrammingSaga = new SoftwareProgrammingSaga();

            var coffeMadeEvent = new CoffeMadeEvent(Guid.NewGuid(), Guid.NewGuid());

            var sagaDataAggregate = Aggregate.Empty <SagaDataAggregate <SoftwareProgrammingSagaData> >(!sagaHasId ? Guid.Empty : Guid.NewGuid());

            sagaDataAggregate.RememberEvent(softwareProgrammingSaga.CoffeReady, !sagaHasData ? null : new SoftwareProgrammingSagaData(""), null);

            var saga = SagaInstance.New(softwareProgrammingSaga, sagaDataAggregate);

            saga.Transit(coffeMadeEvent);
            //No exception is raised
        }
コード例 #6
0
        public void Given_instance_saga_When_recovering_from_creation()
        {
            var aggregateFactory = new AggregateFactory();
            var sagaId           = Guid.NewGuid();

            _data = aggregateFactory.Build <SagaDataAggregate <SoftwareProgrammingSagaData> >(sagaId);
            var saga         = new SoftwareProgrammingSaga();
            var initialState = new SoftwareProgrammingSagaData(saga.MakingCoffee.Name);

            var eventsToReplay = new DomainEvent[]
            {
                new SagaCreatedEvent <SoftwareProgrammingSagaData>(initialState, sagaId)
            };

            _data.ApplyEvents(eventsToReplay);

            _sagaInstance = SagaInstance.New(saga, _data);

            //Try to transit saga by message, available only in desired state
            _coffeMakeFailedEvent = new CoffeMakeFailedEvent(Guid.NewGuid(), Guid.NewGuid());
            _sagaInstance.Transit(_coffeMakeFailedEvent);
            _dispatchedCommands = _sagaInstance.CommandsToDispatch;
        }
コード例 #7
0
 public ISagaInstance <SoftwareProgrammingSaga, SoftwareProgrammingSagaData> Create(SagaDataAggregate <SoftwareProgrammingSagaData> message)
 {
     return(SagaInstance.New(new SoftwareProgrammingSaga(), message));
 }
コード例 #8
0
 public int GetHashCode(SagaInstance <T> message)
 {
     return(message.Saga.CorrelationId.GetHashCode());
 }
コード例 #9
0
 public bool Equals(SagaInstance <T> x, SagaInstance <T> y)
 {
     return(Equals(x.Saga.CorrelationId, y.Saga.CorrelationId));
 }
コード例 #10
0
 public InMemorySagaConsumeContext(ConsumeContext <TMessage> context, SagaInstance <TSaga> instance)
     : base(context)
 {
     _instance = instance;
 }
コード例 #11
0
 public InMemorySagaConsumeContext(ConsumeContext <TMessage> context, SagaInstance <TSaga> saga)
     : base(context, saga.Instance)
 {
     _saga = saga;
 }