コード例 #1
0
        public void ShouldAddEventToUncommittedEvents()
        {
            // Act
            _sut.DoSomething();

            // Assert
            _sut.GetUncommittedEvents().ShouldNotBeEmpty();
        }
コード例 #2
0
        public void ClearUncommittedEvents_RemovesAllUncommitedEvents()
        {
            var aggregate = new TestAggregate(Guid.NewGuid());

            aggregate.ClearUncommittedEvents();

            aggregate.GetUncommittedEvents().Should().BeEmpty();
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }