public async Task Given_persisted_snapshot_Aggregate_should_execute_command() { var aggregate = new Balloon(Guid.NewGuid().ToString(), "haha"); aggregate.WriteNewTitle(10); aggregate.ClearUncommitedEvents(); var repo = new AggregateSnapshotRepository(AutoTestNodeDbConfiguration.Default.JournalConnectionString, new BalloonAggregateFactory(), new BalloonAggregateFactory()); await repo.Add(aggregate); var cmd = new IncreaseTitleCommand(1, aggregate.Id); var res = await Node.Prepare(cmd) .Expect <BalloonTitleChanged>() .Execute(); var message = res.Received; //Values_should_be_equal() Assert.Equal("11", message.Value); //Ids_should_be_equal() Assert.Equal(aggregate.Id, message.SourceId); }
public void Test() { _aggregate = new SampleAggregate(Guid.NewGuid(), "test"); _aggregate.ChangeState(10); _aggregate.ClearEvents(); var repo = new AggregateSnapshotRepository(AkkaConf.Persistence.JournalConnectionString, GridNode.AggregateFromSnapshotsFactory); repo.Add(_aggregate); _restoredAggregate = LoadAggregate <SampleAggregate>(_aggregate.Id); }
public void Test() { _sagaState = new SoftwareProgrammingSagaState(Guid.NewGuid(), SoftwareProgrammingSaga.States.MakingCoffee); _sagaState.RememberPerson(Guid.NewGuid()); _sagaState.RememberBadCoffeMachine(Guid.NewGuid()); _sagaState.ClearEvents(); var repo = new AggregateSnapshotRepository(AkkaConf.Persistence.JournalConnectionString, GridNode.AggregateFromSnapshotsFactory); repo.Add(_sagaState); _restoredState = LoadSagaState <SoftwareProgrammingSaga, SoftwareProgrammingSagaState>(_sagaState.Id); }
public void Test() { var saga = new SoftwareProgrammingSaga(); var state = new SoftwareProgrammingSagaData(saga.Coding.Name, Guid.NewGuid(), Guid.NewGuid()); _sagaState = new SagaDataAggregate <SoftwareProgrammingSagaData>(Guid.NewGuid(), state); _sagaState.RememberEvent(saga.CoffeReady, state, new object()); _sagaState.ClearEvents(); var repo = new AggregateSnapshotRepository(AkkaConf.Persistence.JournalConnectionString, GridNode.AggregateFromSnapshotsFactory); repo.Add(_sagaState); _restoredState = LoadInstanceSagaState <SoftwareProgrammingSaga, SoftwareProgrammingSagaData>(_sagaState.Id); }
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); }