Пример #1
0
        public async Task State_is_changed_on_using_non_generic_transit_method()
        {
            var    given = new Given_Automatonymous_Process(m => m.MakingCoffee);
            object msg   = new CoffeMadeEvent(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            await given.Process.Transit(given.State, msg);

            Assert.Equal(nameof(SoftwareProgrammingProcess.Coding), given.State.CurrentStateName);
        }
Пример #2
0
        public void State_is_changed_on_using_non_generic_transit_method()
        {
            var    given = new Given_AutomatonymousSaga(m => m.MakingCoffee);
            object msg   = new CoffeMadeEvent(Guid.NewGuid(), Guid.NewGuid());

            given.SagaInstance.Transit(msg);
            Assert.AreEqual(given.SagaMachine.Coding.Name, given.SagaDataAggregate.Data.CurrentStateName);
        }
Пример #3
0
        public void State_is_changed_on_using_non_generic_transit_method()
        {
            var given = new Given_State_SoftareProgramming_Saga(SoftwareProgrammingSaga.States.MakingCoffee);

            object msg = new CoffeMadeEvent(Guid.NewGuid(), Guid.NewGuid());

            given.SagaMachine.Transit(msg);
            Assert.AreEqual(SoftwareProgrammingSaga.States.Coding, given.SagaMachine.State.MachineState);
        }
Пример #4
0
        public void Saga_data_should_not_be_changed()
        {
            _coffeMadeEvent = (CoffeMadeEvent)
                              new CoffeMadeEvent(Guid.NewGuid(), Guid.NewGuid()).CloneWithSaga(Guid.NewGuid());

            GridNode.Transport.Publish(_coffeMadeEvent);
            Thread.Sleep(200);
            _sagaDataAggregate = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(_coffeMadeEvent.SagaId);
            Assert.Null(_sagaDataAggregate.Data);
        }
        public async Task Process_state_should_not_be_changed()
        {
            var coffeMadeEvent = new CoffeMadeEvent(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), null, Guid.NewGuid().ToString());

            Node.Transport.Publish(coffeMadeEvent);
            await Task.Delay(200);

            var processStateAggregate =
                await this.LoadAggregateByActor <ProcessStateAggregate <SoftwareProgrammingState> >(coffeMadeEvent.ProcessId);

            Assert.Null(processStateAggregate.State);
        }
Пример #6
0
        public void Message_received_event_contains_incoming_message()
        {
            var given = new Given_AutomatonymousSaga(m => m.MakingCoffee);

            ClearEvents(given.SagaDataAggregate);
            var message = new CoffeMadeEvent(Guid.NewGuid(), Guid.NewGuid());

            When_execute_valid_transaction(given.SagaInstance, message);
            var stateChangeEvent = GetFirstOf <SagaMessageReceivedEvent <SoftwareProgrammingSagaData> >(given.SagaDataAggregate);

            Assert.AreEqual(message, stateChangeEvent.Message);
        }
            public ProcessHubInfrastructure()
            {
                var processId = Guid.NewGuid().ToString();

                ChildId = processId;
                var gotTired       = new GotTiredEvent(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), processId);
                var coffeMadeEvent = new CoffeMadeEvent(gotTired.FavoriteCoffeMachineId, gotTired.PersonId, null, processId);

                ChildCreateMessage = new MessageMetadataEnvelop <DomainEvent>(gotTired, MessageMetadata.New(gotTired.SourceId, null, null));
                //TODO: second message will not hit same process as created by previos,
                //think how to change it.
                ChildActivateMessage = new MessageMetadataEnvelop <DomainEvent>(coffeMadeEvent,
                                                                                MessageMetadata.New(coffeMadeEvent.SourceId, null, null));
            }
Пример #8
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
        }
        public StateSagaPersistedHub_Infrastructure(ActorSystem system)
        {
            var sagaId = Guid.NewGuid();

            ChildId = sagaId;
            var gotTired       = new GotTiredEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), sagaId);
            var coffeMadeEvent = new CoffeMadeEvent(gotTired.FavoriteCoffeMachineId, gotTired.PersonId, null, sagaId);

            ChildCreateMessage = new MessageMetadataEnvelop <DomainEvent>(gotTired,
                                                                          new MessageMetadata(gotTired.SourceId));

            ChildActivateMessage = new MessageMetadataEnvelop <DomainEvent>(coffeMadeEvent,
                                                                            new MessageMetadata(coffeMadeEvent.SourceId));

            HubProps = system.DI().Props <SagaHubActor <SoftwareProgrammingSaga, SoftwareProgrammingSagaState> >();
        }
        public void When_publishing_start_message()
        {
            _startMessage = (GotTiredEvent)
                            new GotTiredEvent(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid())
                            .CloneWithSaga(Guid.NewGuid());

            _coffeMadeEvent = (CoffeMadeEvent)
                              new CoffeMadeEvent(_startMessage.FavoriteCoffeMachineId, _startMessage.PersonId)
                              .CloneWithSaga(_startMessage.SagaId);

            _reStartEvent = (GotTiredEvent)
                            new GotTiredEvent(Guid.NewGuid(), _startMessage.LovelySofaId, Guid.NewGuid())
                            .CloneWithSaga(_startMessage.SagaId);

            GridNode.Transport.Publish(_startMessage);
            GridNode.Transport.Publish(_coffeMadeEvent);
            GridNode.Transport.Publish(_reStartEvent);

            Thread.Sleep(3000);

            _sagaDataAggregate = LoadAggregate <SagaDataAggregate <SoftwareProgrammingSagaData> >(_startMessage.SagaId);
        }
Пример #11
0
 public void Handle(CoffeMadeEvent msg)
 {
     TransitState(msg);
 }