Exemplo n.º 1
0
        public void Applying_an_event_should_at_it_to_the_uncommited_events()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            theAggregate.GetUncommittedEvents().Count().Should().Be(1);

            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            theAggregate.GetUncommittedEvents().Count().Should().Be(2);
        }
Exemplo n.º 2
0
        public void Applying_an_event_should_at_it_to_the_uncommited_events()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            theAggregate.GetUncommittedEvents().Count().Should().Be(1);

            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            theAggregate.GetUncommittedEvents().Count().Should().Be(2);
        }
Exemplo n.º 3
0
        public void Applying_an_event_should_at_it_to_the_uncommited_events()
        {
            using (NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork())
            {
                var theAggregate = new MyAggregateRoot();

                theAggregate.MethodThatCausesAnEventThatHasAHandler();

                theAggregate.GetUncommittedEvents().Count().Should().Be(1);

                theAggregate.MethodThatCausesAnEventThatHasAHandler();

                theAggregate.GetUncommittedEvents().Count().Should().Be(2);
            }
        }
Exemplo n.º 4
0
        public void Applying_an_event_should_affect_the_version()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.Version.Should().Be(0);

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.Version.Should().Be(1);
            theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(1);

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.Version.Should().Be(2);
            theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(2);

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
        }
Exemplo n.º 5
0
        public void Applying_an_event_should_affect_the_version()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.Version.Should().Be(0);

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.Version.Should().Be(1);
            theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(1);

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.Version.Should().Be(2);
            theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(2);

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
        }
Exemplo n.º 6
0
        public void Getting_the_uncommitted_via_the_IEventSource_interface_should_return_the_same_as_directly()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            var directResult       = theAggregate.GetUncommittedEvents();
            var viaInterfaceResult = ((IEventSource)theAggregate).GetUncommittedEvents();

            directResult.Should().BeEquivalentTo(viaInterfaceResult);
        }
Exemplo n.º 7
0
        public void Accepting_the_changes_should_clear_the_uncommitted_events()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            theAggregate.AcceptChanges();

            theAggregate.GetUncommittedEvents().Should().BeEmpty();
        }
Exemplo n.º 8
0
        public void Accepting_the_changes_should_clear_the_uncommitted_events()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            theAggregate.AcceptChanges();

            theAggregate.GetUncommittedEvents().Should().BeEmpty();
        }
Exemplo n.º 9
0
        public void Accepting_the_changes_should_clear_the_uncommitted_events()
        {
            using (NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork())
            {
                var theAggregate = new MyAggregateRoot();

                theAggregate.MethodThatCausesAnEventThatHasAHandler();
                theAggregate.MethodThatCausesAnEventThatHasAHandler();
                theAggregate.MethodThatCausesAnEventThatHasAHandler();
                theAggregate.MethodThatCausesAnEventThatHasAHandler();
                theAggregate.MethodThatCausesAnEventThatHasAHandler();

                theAggregate.AcceptChanges();

                theAggregate.GetUncommittedEvents().Should().BeEmpty();
            }
        }
Exemplo n.º 10
0
        public void It_should_initialize_with_no_uncommited_events()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.GetUncommittedEvents().Count().Should().Be(0);
        }
Exemplo n.º 11
0
        public void Getting_the_uncommitted_via_the_IEventSource_interface_should_return_the_same_as_directly()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.MethodThatCausesAnEventThatHasAHandler();
            theAggregate.MethodThatCausesAnEventThatHasAHandler();

            var directResult = theAggregate.GetUncommittedEvents();
            var viaInterfaceResult = ((IEventSource) theAggregate).GetUncommittedEvents();
            directResult.Should().BeEquivalentTo(viaInterfaceResult);
        }
Exemplo n.º 12
0
        public void It_should_initialize_with_no_uncommited_events()
        {
            var theAggregate = new MyAggregateRoot();

            theAggregate.GetUncommittedEvents().Count().Should().Be(0);
        }
Exemplo n.º 13
0
        public void Applying_an_event_should_the_the_version()
        {
            using (NcqrsEnvironment.Get<IUnitOfWorkFactory>().CreateUnitOfWork())
            {
                var theAggregate = new MyAggregateRoot();

                theAggregate.Version.Should().Be(0);

                theAggregate.MethodThatCausesAnEventThatHasAHandler();
                theAggregate.Version.Should().Be(1);
                theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(1);

                theAggregate.MethodThatCausesAnEventThatHasAHandler();
                theAggregate.Version.Should().Be(2);
                theAggregate.GetUncommittedEvents().Last().EventSequence.Should().Be(2);

                theAggregate.MethodThatCausesAnEventThatHasAHandler();
            }
        }