Пример #1
0
        public async Task ShouldCommitAEventWHenAnyEntityNotBeSaved()
        {
            var expectedEvent = new FakeCelebrityEvent(Guid.NewGuid().ToString(), new { Foo = "Foo", Bar = "Bar" });
            await _eventStore.Commit(expectedEvent);

            await CheckIfItemExist(expectedEvent);
        }
Пример #2
0
        public async Task ShouldAppendTheNewEventToExistingRecord()
        {
            var expectedAggreagatedId = Guid.NewGuid().ToString();
            var fisrtEvent            = new FakeCelebrityEvent(expectedAggreagatedId, new { Foo = "Foo", Bar = "Bar" });
            await _eventStore.Commit(fisrtEvent);

            var secondEvent = new FakeCelebrityEvent(expectedAggreagatedId, new { Foo = "Foo", Bar = "Bar" });
            await _eventStore.Commit(secondEvent);

            await CheckIfItemExist(secondEvent);
        }
Пример #3
0
        public async Task ShouldReturnEventsRelatedByAggregatedId()
        {
            var expectedAggreagatedId = Guid.NewGuid().ToString();
            var fisrtEvent            = new FakeCelebrityEvent(expectedAggreagatedId, new { Foo = "Foo", Bar = "Bar" });
            await _eventStore.Commit(fisrtEvent);

            var secondEvent = new FakeCelebrityEvent(expectedAggreagatedId, new { Foo = "Foo", Bar = "Bar" });
            await _eventStore.Commit(secondEvent);

            var result = await _eventStore.Get(fisrtEvent.AggregatedId);

            result.Should().BeAssignableTo <IReadOnlyCollection <ICelebrityEvent> >();
        }
Пример #4
0
        public void ShouldAppendEventToPpenddingEventsQueue()
        {
            var expectedAggregatedId = Guid.NewGuid().ToString();
            var fisrtEvent           = new FakeCelebrityEvent(expectedAggregatedId, new { Id = expectedAggregatedId, Foo = "Bar", Bar = "Foo" });
            var events = new Queue <ICelebrityEvent>();

            events.Enqueue(fisrtEvent);

            var fooBar = new FooBar(events);

            fooBar.RevertPropertyValues();

            var pendingEvent = fooBar.PendingEvents.Should().HaveCount(1).And.Subject.First();

            pendingEvent.AggregatedId.Should().Be(expectedAggregatedId);
            pendingEvent.Data.Should().Be(new { Id = expectedAggregatedId, Foo = "Foo", Bar = "Bar" });
        }
Пример #5
0
        public void ShouldReduceEventsToEntityInYourLastStateWhenExistCommitedEvents()
        {
            var expectedAggregatedId = Guid.NewGuid().ToString();
            var events      = new Queue <ICelebrityEvent>();
            var fisrtEvent  = new FakeCelebrityEvent(expectedAggregatedId, new { Foo = "Bar", Bar = "Foo" });
            var secondEvent = new FakeCelebrityEvent(expectedAggregatedId, new { Foo = "Foo", Bar = "Bar" });

            events.Enqueue(fisrtEvent);
            events.Enqueue(secondEvent);

            var fooBar = new FooBar(events);

            var reduced = fooBar.GetState();

            reduced.Should().NotBeEquivalentTo(fisrtEvent.Data);
            reduced.Should().BeEquivalentTo(secondEvent.Data);
        }