Пример #1
0
        protected async Task Given_No_Existing_Stream_When_The_Snapshot_Is_Added_Then_An_Error_Is_Raised(IEventStoreProvider eventStoreProvider)
        {
            // Arrange
            string    eventStreamId    = Guid.NewGuid().ToEventStreamIdFormattedString();
            string    snapshotStreamId = string.Format(CultureInfo.InvariantCulture, "{0}-snapshot", eventStreamId);
            Guid      snapshotId       = Guid.NewGuid();
            const int streamRevision   = 3;

            // Act
            EventStoreSnapshot eventStoreSnapshotToBeWritten = new EventStoreSnapshot(snapshotId, streamRevision, new object());

            // Assert
            await AssertExtensions.ThrowsAsync <EventStreamNotFoundException>(
                async() => await eventStoreProvider.AddSnapshotAsync(eventStreamId, snapshotStreamId, eventStoreSnapshotToBeWritten).ConfigureAwait(false)).ConfigureAwait(false);
        }
Пример #2
0
        protected async Task Given_A_Snapshot_Of_Different_Type_Exists_When_Checking_A_Snapshot_Then_False_Is_Returned(IEventStoreProvider eventStoreProvider)
        {
            // Arrange
            string    eventStreamId    = Guid.NewGuid().ToEventStreamIdFormattedString();
            string    snapshotStreamId = string.Format(CultureInfo.InvariantCulture, "{0}-snapshot", eventStreamId);
            Guid      snapshotId       = Guid.NewGuid();
            const int streamRevision   = 3;

            // Act
            eventStoreProvider.AppendEvents(eventStreamId, new object(), new object(), new object());
            await eventStoreProvider.CommitEventsAsync(eventStreamId, ExpectedStreamRevision.New).ConfigureAwait(false);

            EventStoreSnapshot eventStoreSnapshotToBeWritten = new EventStoreSnapshot(snapshotId, streamRevision, new object());
            await eventStoreProvider.AddSnapshotAsync(eventStreamId, snapshotStreamId, eventStoreSnapshotToBeWritten).ConfigureAwait(false);

            bool snapshotExists = await eventStoreProvider.CheckSnapshotExistsAsync <TestAggregateSnapshot>(snapshotStreamId).ConfigureAwait(false);

            // Assert
            Assert.False(snapshotExists);
        }
Пример #3
0
        protected async Task Given_A_Valid_Snapshot_When_The_Snapshot_Is_Added_Then_The_Snapshot_Can_Be_Read_And_The_Retrieved_Snapshot_Has_The_Correct_Metadata(IEventStoreProvider eventStoreProvider)
        {
            // Arrange
            string    eventStreamId    = Guid.NewGuid().ToEventStreamIdFormattedString();
            string    snapshotStreamId = string.Format(CultureInfo.InvariantCulture, "{0}-snapshot", eventStreamId);
            Guid      snapshotId       = Guid.NewGuid();
            const int streamRevision   = 3;

            // Act
            eventStoreProvider.AppendEvents(eventStreamId, new object(), new object(), new object());
            await eventStoreProvider.CommitEventsAsync(eventStreamId, ExpectedStreamRevision.New).ConfigureAwait(false);

            EventStoreSnapshot eventStoreSnapshotToBeWritten = new EventStoreSnapshot(snapshotId, streamRevision, new object());
            await eventStoreProvider.AddSnapshotAsync(eventStreamId, snapshotStreamId, eventStoreSnapshotToBeWritten).ConfigureAwait(false);

            EventStoreSnapshot eventStoreSnapshotThatWasRead = await eventStoreProvider.ReadSnapshotAsync(snapshotStreamId).ConfigureAwait(false);

            // Assert
            Assert.NotNull(eventStoreSnapshotThatWasRead);
            Assert.Equal(snapshotId, eventStoreSnapshotThatWasRead.SnapshotId);
            Assert.Equal(streamRevision, eventStoreSnapshotThatWasRead.StreamRevision);
            Assert.Equal(3, eventStoreSnapshotThatWasRead.Headers.Count);
        }