public async Task Should_write_state_and_events_when_created() { await SetupEmptyAsync(); var result = await sut.ExecuteAsync(C(new CreateAuto { Value = 5 })); A.CallTo(() => persistence.WriteSnapshotAsync(A <MyDomainState> .That.Matches(x => x.Value == 5))) .MustHaveHappened(); A.CallTo(() => persistence.WriteEventsAsync(A <IEnumerable <Envelope <IEvent> > > .That.Matches(x => x.Count() == 1))) .MustHaveHappened(); Assert.True(result.Value is EntityCreatedResult <Guid>); Assert.Empty(sut.GetUncomittedEvents()); Assert.Equal(5, sut.Snapshot.Value); }
public async Task Should_write_state_and_events_when_created() { SetupEmpty(); var result = await sut.ExecuteAsync(new CreateAuto { Value = 4 }); A.CallTo(() => persistence.WriteSnapshotAsync(A <MyDomainState> .That.Matches(x => x.Value == 4))) .MustHaveHappened(); A.CallTo(() => persistence.WriteEventsAsync(A <IReadOnlyList <Envelope <IEvent> > > .That.Matches(x => x.Count == 1))) .MustHaveHappened(); A.CallTo(() => persistence.ReadAsync(A <long> ._)) .MustNotHaveHappened(); Assert.Equal(CommandResult.Empty(id, 0, EtagVersion.Empty), result); Assert.Empty(sut.GetUncomittedEvents()); AssertSnapshot(sut.Snapshot, 4, 0); }
public async Task Should_write_state_and_events_when_created() { SetupEmpty(); var result = await sut.ExecuteAsync(new CreateAuto { Value = 4 }); A.CallTo(() => persistence.WriteSnapshotAsync(A <MyDomainState> .That.Matches(x => x.Value == 4))) .MustHaveHappened(); A.CallTo(() => persistence.WriteEventsAsync(A <IEnumerable <Envelope <IEvent> > > .That.Matches(x => x.Count() == 1))) .MustHaveHappened(); A.CallTo(() => persistence.ReadAsync(A <long> ._)) .MustNotHaveHappened(); Assert.True(result is EntityCreatedResult <DomainId>); Assert.Empty(sut.GetUncomittedEvents()); Assert.Equal(4, sut.Snapshot.Value); Assert.Equal(0, sut.Snapshot.Version); }