Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }