Beispiel #1
0
        public void WhenDomainActionPerformed_ThenObjectHasEvents()
        {
            var root = new TestRoot();

            root.Publish(5);

            Assert.True(root.GetEvents().Any());

            root.AcceptEvents();

            Assert.False(root.GetEvents().Any());
        }
Beispiel #2
0
        public void WhenDomainActionPerformed_ThenRootChangesStateThroughEvent()
        {
            var root = new TestRoot();

            root.Publish(5);

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

            root.AcceptEvents();

            Assert.False(root.GetEvents().Any());
        }
Beispiel #3
0
        public void WhenLoadingFromEvent_ThenRootChangesState()
        {
            var events = new DomainEvent[] { new TestPublished {
                                                 Version = 5
                                             } };
            var root = new TestRoot(events);

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

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

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