private async Task SetupCreatedAsync() { await sut.ActivateAsync(id); await sut.ExecuteAsync(C(new CreateAuto { Value = 4 })); }
public async Task Should_write_state_and_events_when_saved() { await sut.ActivateAsync(id, store); var event1 = new MyEvent(); var event2 = new MyEvent(); var newState = new MyDomainState(); sut.RaiseEvent(event1); sut.RaiseEvent(event2); sut.UpdateState(newState); await sut.WriteAsync(A.Fake <ISemanticLog>()); A.CallTo(() => persistence.WriteSnapshotAsync(newState)) .MustHaveHappened(); A.CallTo(() => persistence.WriteEventsAsync(A <IEnumerable <Envelope <IEvent> > > .That.Matches(x => x.Count() == 2))) .MustHaveHappened(); Assert.Empty(sut.GetUncomittedEvents()); }
public AggregateHandlerTests() { command = new MyCommand { AggregateId = domainObjectId, ExpectedVersion = EtagVersion.Any }; context = new CommandContext(command, A.Dummy <ICommandBus>()); A.CallTo(() => store.WithSnapshotsAndEventSourcing(domainObjectId, A <Func <MyDomainState, Task> > .Ignored, A <Func <Envelope <IEvent>, Task> > .Ignored)) .Returns(persistence); A.CallTo(() => stateFactory.CreateAsync <MyDomainObject>(domainObjectId)) .Returns(Task.FromResult(domainObject)); A.CallTo(() => stateFactory.GetSingleAsync <MyDomainObject>(domainObjectId)) .Returns(Task.FromResult(domainObject)); sut = new AggregateHandler(stateFactory, serviceProvider); domainObject.ActivateAsync(domainObjectId, store).Wait(); }