Example #1
0
        public void WhenDomainActionPerformed_ThenRootChangesStateThroughEvent()
        {
            var root = new TestRoot();

            root.Publish(5);

            Assert.Equal(5, root.LatestVersion);
            Assert.True(root.GetChanges().Any());
            Assert.True(root.GetChanges().OfType <TestPublished>().Any(x => x.Version == 5));

            root.AcceptChanges();

            Assert.False(root.GetChanges().Any());
        }
Example #2
0
        public void WhenLoadingFromEvent_ThenRootChangesState()
        {
            var root   = new TestRoot();
            var events = new TimestampedEventArgs[] { new TestPublished {
                                                          Version = 5
                                                      } };

            root.Load(events);

            Assert.Equal(5, root.LatestVersion);
            Assert.False(root.GetChanges().Any());

            // This should be no-op now.
            root.AcceptChanges();

            Assert.False(root.GetChanges().Any());
        }