public async Task When_process_produce_command_and_waiting_for_it_fault() { var givenProcessStateAggregate = new ProcessStateAggregate <SoftwareProgrammingState>(new SoftwareProgrammingState(Guid.NewGuid().ToString(), nameof(SoftwareProgrammingProcess.MakingCoffee)) { PersonId = Guid.NewGuid().ToString() }); await Node.SaveToJournal(givenProcessStateAggregate); var coffeMakeFailedEvent = new CoffeMakeFailedEvent(Guid.NewGuid().ToString(), givenProcessStateAggregate.State.PersonId, BusinessDateTime.UtcNow, givenProcessStateAggregate.Id); await Node.NewDebugWaiter() .Expect <ProcessReceivedMessage <SoftwareProgrammingState> >(m => m.State.CurrentStateName == nameof(SoftwareProgrammingProcess.Coding)) .Create() .SendToProcessManagers(coffeMakeFailedEvent, MessageMetadata.New(coffeMakeFailedEvent.SourceId, null, null)); var processStateAggregate = await this.LoadProcessByActor <SoftwareProgrammingState>(givenProcessStateAggregate.Id); //Process_should_be_in_correct_state_after_fault_handling() Assert.Equal(nameof(SoftwareProgrammingProcess.Coding), processStateAggregate.CurrentStateName); //Process_state_should_contain_data_from_fault_message() Assert.Equal(coffeMakeFailedEvent.ForPersonId, processStateAggregate.BadSleepPersonId); }
public void Test() { var state = new SoftwareProgrammingState(Guid.NewGuid().ToString(), "123", Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); var processStateAggregate = new ProcessStateAggregate <SoftwareProgrammingState>(state); processStateAggregate.ReceiveMessage(state, Guid.NewGuid().ToString()); processStateAggregate.ClearUncommitedEvents(); var jsonSerializerSettings = DomainSerializer.GetDefaultSettings(); jsonSerializerSettings.TraceWriter = new XUnitTraceWriter(_testOutputHelper); var json = JsonConvert.SerializeObject(processStateAggregate, jsonSerializerSettings); var restoredState = JsonConvert.DeserializeObject <ProcessStateAggregate <SoftwareProgrammingState> >(json, jsonSerializerSettings); restoredState.ClearUncommitedEvents(); //CoffeMachineId_should_be_equal() Assert.Equal(processStateAggregate.State.CoffeeMachineId, restoredState.State.CoffeeMachineId); // Id_should_be_equal() Assert.Equal(processStateAggregate.Id, restoredState.Id); //State_should_be_equal() Assert.Equal(processStateAggregate.State.CurrentStateName, restoredState.State.CurrentStateName); }
public async Task Test() { var i = Node.Id; //just start node var process = new SoftwareProgrammingProcess(); var state = new SoftwareProgrammingState(Guid.NewGuid().ToString(), process.Coding.Name, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); var processStateAggregate = new ProcessStateAggregate <SoftwareProgrammingState>(state); processStateAggregate.ReceiveMessage(state, null); processStateAggregate.ClearUncommitedEvents(); var repo = new AggregateSnapshotRepository(AutoTestNodeDbConfiguration.Default.JournalConnectionString, AggregateFactory.Default, AggregateFactory.Default); await repo.Add(processStateAggregate); var restoredState = await this.LoadProcessByActor <SoftwareProgrammingState>(processStateAggregate.Id); //CoffeMachineId_should_be_equal() Assert.Equal(processStateAggregate.State.CoffeeMachineId, restoredState.CoffeeMachineId); // State_should_be_equal() Assert.Equal(processStateAggregate.State.CurrentStateName, restoredState.CurrentStateName); }