public async Task ShouldCommitAEventWHenAnyEntityNotBeSaved() { var expectedEvent = new FakeCelebrityEvent(Guid.NewGuid().ToString(), new { Foo = "Foo", Bar = "Bar" }); await _eventStore.Commit(expectedEvent); await CheckIfItemExist(expectedEvent); }
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); }
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> >(); }
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" }); }
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); }