public async Task SetupAggregate_VerifyAppendToStream() { var serializer = new JsonEventSerializer(JsonSerializer.CreateDefault()); var settings = new VerifiableEventStoreSettings(serializer); var eventStore = new VerifiableEventStore(settings); var aggregate = Goat.Create("g047"); aggregate.Rename("goatl"); await aggregate.CommitAsync(eventStore); eventStore.VerifyAppendToStream(aggregate, ExpectedVersion.NoStream, verify => verify .Event(GoatCreated.EventType, e => { Assert.Equal("g047", e.Name); }) .Event(GoatRenamed.EventType, e => { Assert.Equal("goatl", e.Name); }) ); var streamVersion = eventStore.CurrentVersion(aggregate); var retrieved = await Goat.FromAsync(eventStore, aggregate.Id); retrieved.Rename("meh"); await retrieved.CommitAsync(eventStore); eventStore.VerifyAppendToStream(aggregate, streamVersion, verify => verify .Event(GoatRenamed.EventType, e => { Assert.Equal("meh", e.Name); }) ); }
public async Task CreateWithNoStream() { var serializer = new JsonEventSerializer(JsonSerializer.CreateDefault()); var settings = new VerifiableEventStoreSettings(serializer); var eventStore = new VerifiableEventStore(settings); var aggregate = Goat.Create("g047"); await aggregate.CommitAsync(eventStore); eventStore.VerifyAppendToStream(aggregate, ExpectedVersion.NoStream, verify => verify .Event(GoatCreated.EventType, e => { Assert.Equal("g047", e.Name); }) ); }