public async Task can_get_snapshot()
        {
            //Given
            var aggregate = new Reviews.Domain.Review();

            aggregate.Apple(AutoFixture.Build <Domain.Events.V1.ReviewCreated>()
                            .With(e => e.Caption, Caption)
                            .With(e => e.Content, Content)
                            .With(e => e.ProductId, ProductId)
                            .With(e => e.Id, AggregateId).Create());
            aggregate.Apple(AutoFixture.Build <Domain.Events.V1.ReviewPublished>().With(e => e.Id, AggregateId).Create());
            aggregate.Apple(AutoFixture.Build <Domain.Events.V1.ReviewApproved>().With(e => e.Id, AggregateId).Create());

            var sut  = new GesSnapshotStore(Connection, null);
            var snap = aggregate.TakeSnapshot();
            await sut.SaveSnapshotAsync <Review>(snap);

            //When
            var result = await sut.GetSnapshotAsync <Review>(AggregateId);

            //Then
            outputHelper.WriteLine($"Snapshot result last Version:{result.Version}");
            result.Should().BeEquivalentTo(new ReviewSnapshot(Guid.Empty, AggregateId, -1, Caption, Content, Status.Approved, ProductId),
                                           o => o.ExcludingFields().Excluding(q => q.Id).Excluding(q => q.CurrentStatus).Excluding(q => q.ProductId));
        }
Ejemplo n.º 2
0
        public async Task can_take_snapshot()
        {
            //Given
            var aggregate = new Reviews.Domain.Review();

            aggregate.Apple(AutoFixture.Create <Domain.Events.V1.ReviewCreated>());
            aggregate.Apple(AutoFixture.Create <Domain.Events.V1.ReviewApproved>());

            var sut = new GesSnapshotStore(Connection, Serializer, EventTypeMapper, (a, b) => $"{a}-{b}", null);

            //When
            var result = await sut.SaveSnapshotAsync(aggregate.TakeSnapshot());

            //Then
            outputHelper.WriteLine($"Snapshot result last position:{result}");
            result.Should().BeGreaterThan(0);
        }