public void ShouldAddEventToUncommittedEvents() { // Act _sut.DoSomething(); // Assert _sut.GetUncommittedEvents().ShouldNotBeEmpty(); }
public void ClearUncommittedEvents_RemovesAllUncommitedEvents() { var aggregate = new TestAggregate(Guid.NewGuid()); aggregate.ClearUncommittedEvents(); aggregate.GetUncommittedEvents().Should().BeEmpty(); }
public void GetUncommittedEvents_ReturnsCopyOfAggregateUncommittedEvents() { var id = Guid.NewGuid(); var aggregate = new TestAggregate(id); var uncommittedEvents = aggregate.GetUncommittedEvents().ToArray(); uncommittedEvents.Should().HaveCount(1); uncommittedEvents.First().Should().BeOfType <TestAggregateCreated>(); uncommittedEvents.Cast <TestAggregateCreated>().First().TestId.Should().Be(id); }
public void ShouldNotSaveSnapshotWithOneExistingSnapshot() { // ARRANGE var testAggregate = new TestAggregate(Guid.NewGuid()); // ACT // Publish 7 events. This should create a snapshot testAggregate.PublishInitialTestEvent(); testAggregate.PublishAddressTestEvent(); testAggregate.PublishInitialTestEvent(); // ASSERT Assert.AreEqual(8, testAggregate.GetUncommittedEvents().Count); }
public void ShouldNotSaveSnapshot() { // ARRANGE var testAggregate = new TestAggregate(Guid.NewGuid()); // ACT // Publish 3 events. This should not create a snapshot testAggregate.PublishInitialTestEvent(); // ASSERT Assert.AreEqual(3, testAggregate.GetUncommittedEvents().Count); Assert.AreEqual("Tigerdyret", testAggregate.State.Name); Assert.AreEqual(33, testAggregate.State.Age); Assert.AreEqual("*****@*****.**", testAggregate.State.Email); }
public void ShouldSaveOneSnapshot() { // ARRANGE var testAggregate = new TestAggregate(Guid.NewGuid()); // ACT // Publish 4 events. This should create a snapshot testAggregate.PublishInitialTestEvent(); testAggregate.PublishAddressTestEvent(); // ASSERT Assert.AreEqual(5, testAggregate.GetUncommittedEvents().Count); Assert.AreEqual("Tigerdyret", testAggregate.State.Name); Assert.AreEqual(33, testAggregate.State.Age); Assert.AreEqual("*****@*****.**", testAggregate.State.Email); Assert.AreEqual("Hundred Acre Wood", testAggregate.State.Address); }