public void FromStorage_takes_initial_version_into_account() { var stored = new[] { new EmptyEvent(), new EmptyEvent(), new EmptyEvent() }; var buffer = EventBuffer.FromStorage(Guid.NewGuid(), initialVersion: 6, stored, (@event) => @event); buffer.Should().HaveCount(3) .And.Subject.As <EventBuffer <Guid> >().CommittedVersion.Should().Be(9); }
public void FromStorage_contains_all_events_as_committed() { var stored = new[] { new EmptyEvent(), new EmptyEvent(), new EmptyEvent() }; var buffer = EventBuffer.FromStorage(Guid.NewGuid(), stored, (@event) => @event); buffer.Should().HaveCount(3) .And.Subject.As <EventBuffer <Guid> >().CommittedVersion.Should().Be(3); }
public Task <Result <EventBuffer <TId> > > LoadAsync(TId aggregateId) { var location = Location(aggregateId); if (!location.Exists) { return(Task.FromResult(Result.WithMessages <EventBuffer <TId> >(EntityNotFound.ForId(aggregateId)))); } else { var buffer = EventBuffer <TId> .FromStorage(aggregateId, Load(location), e => e); return(Task.FromResult(Result.For(buffer))); } }
public void FromStorage_with_version() => Assert.That(() => EventBuffer <int> .FromStorage(1, 0, Array.Empty <object>(), e => e), Is.Not.Null);
private static EventBuffer <Guid> Create(Guid id, params object[] events) { return(EventBuffer.FromStorage(id, events, o => o)); }