public void Stream_DefaultsCorrect() { var stream = new AggregateEventStream<Guid>(); stream.IsTruncated.Should().BeFalse(); stream.Version.Should().Be(0); stream.CommittedVersion.Should().Be(0); }
private static AggregateEventStream <HotelAggregate> GetStream(IEventStoreFacade connection, IAggregateSchema <HotelAggregate> schema) { AggregateEventStream <HotelAggregate> stream = new AggregateEventStream <HotelAggregate>(connection, new EventConverter(), new EventDataFactory(), new EventMetadataFactory <HotelAggregate>(), schema, Logger.None); return(stream); }
public void Appending_WithGaps_ThrowsException() { var stream = new AggregateEventStream<ServiceCaseId>(); var outOfOrderEvent = new ServiceCase.CommunicationThreadStarted(1, ServiceCase.SampleContent.Topic, ServiceCase.SampleContent.TopicDescription, ServiceCase.SampleContent.ResponsibleParty, _id, 3); stream.AppendEvent(_openedEvent); stream.Invoking(x => x.AppendEvent(outOfOrderEvent)) .ShouldThrow<InvalidOperationException>(); }
public void AppendingInitialEvent_EventStreamsAndVersionCorrect() { var stream = new AggregateEventStream<ServiceCaseId>(); stream.AppendEvent(_openedEvent); stream.Events.Count().Should().Be(1); stream.UncommittedEvents.Count().Should().Be(1); stream.CommittedEvents.Count().Should().Be(0); stream.CommittedVersion.Should().Be(0); stream.Version.Should().Be(1); stream.UncommittedEvents.First().Should().Be(_openedEvent); }
public void AppendingInitialEvent_WithVersionGreaterThanOne_IsTruncated() { var stream = new AggregateEventStream<ServiceCaseId>(); stream.AppendEvent(new ServiceCase.CommunicationThreadStarted(1, ServiceCase.SampleContent.Topic, ServiceCase.SampleContent.TopicDescription, ServiceCase.SampleContent.ResponsibleParty, _id, 7)); stream.IsTruncated.Should().BeTrue(); }
public void AppendingInitialEvent_WithVersionEqualToOne_IsNotTruncated() { var stream = new AggregateEventStream<ServiceCaseId>(); stream.AppendEvent(_openedEvent); stream.IsTruncated.Should().BeFalse(); }
public void CommittingEvents_UpToVersion_WhenStreamIsTruncated_YieldsSomeCommittedEvents() { var stream = new AggregateEventStream<ServiceCaseId>(); var e1 = new ServiceCase.CommunicationThreadStarted(1, ServiceCase.SampleContent.Topic, ServiceCase.SampleContent.TopicDescription, ServiceCase.SampleContent.ResponsibleParty, _id, 7); var e2 = new ServiceCase.CommunicationRecorded(1, CommunicationDirection.Incoming, ServiceCase.SampleContent.CommunicationContent, SystemClock.UtcNow, ServiceCase.SampleContent.CommunicationDuration, ServiceCase.SampleContent.ResponsibleParty, _id, 8); var e3 = new ServiceCase.CommunicationRecorded(1, CommunicationDirection.Incoming, ServiceCase.SampleContent.CommunicationContent, SystemClock.UtcNow, ServiceCase.SampleContent.CommunicationDuration, ServiceCase.SampleContent.ResponsibleParty, _id, 9); stream.AppendEvent(e1); stream.AppendEvent(e2); stream.AppendEvent(e3); stream.CommitEvents(8); stream.Events.Count().Should().Be(3); stream.UncommittedEvents.Count().Should().Be(1); stream.CommittedEvents.Count().Should().Be(2); stream.CommittedVersion.Should().Be(8); stream.Version.Should().Be(9); stream.CommittedEvents.ElementAt(0).Should().Be(e1); stream.CommittedEvents.ElementAt(1).Should().Be(e2); stream.UncommittedEvents.ElementAt(0).Should().Be(e3); }
public void CommittingManyEvents_EventStreamsAndVersionCorrect() { var stream = new AggregateEventStream<ServiceCaseId>(); var e2 = new ServiceCase.CommunicationThreadStarted(1, ServiceCase.SampleContent.Topic, ServiceCase.SampleContent.TopicDescription, ServiceCase.SampleContent.ResponsibleParty, _id, 2); var e3 = new ServiceCase.CommunicationRecorded(1, CommunicationDirection.Incoming, ServiceCase.SampleContent.CommunicationContent, SystemClock.UtcNow, ServiceCase.SampleContent.CommunicationDuration, ServiceCase.SampleContent.ResponsibleParty, _id, 3); stream.AppendEvent(_openedEvent); stream.AppendEvent(e2); stream.AppendEvent(e3); stream.CommitEvents(); stream.Events.Count().Should().Be(3); stream.UncommittedEvents.Count().Should().Be(0); stream.CommittedEvents.Count().Should().Be(3); stream.CommittedVersion.Should().Be(3); stream.Version.Should().Be(3); stream.CommittedEvents.ElementAt(0).Should().Be(_openedEvent); stream.CommittedEvents.ElementAt(1).Should().Be(e2); stream.CommittedEvents.ElementAt(2).Should().Be(e3); }