コード例 #1
0
        public void When_Applying_Event_And_Clearing_Uncomitted()
        {
            var subject = new AggregateStub(Guid.NewGuid());

            var newEvent = new EventStubTypeC();
            subject.ApplyEventToAggregate(newEvent);
            subject.ClearUncomittedEvents();

            Assert.That(subject.GetUncomittedEvents(), Is.Empty);
        }
コード例 #2
0
        public void When_Loading_From_Event_History()
        {
            var subject = new AggregateStub(Guid.NewGuid());
            var history = new List<EventBaseV1> { new EventStubTypeA(), new EventStubTypeB() };

            subject.LoadFromHistory(history);
            Assert.That(subject.GetUncomittedEvents(), Is.Empty);
            Assert.That(subject.EventTypeAApplied, Is.True);
            Assert.That(subject.EventTypeBApplied, Is.True);
        }
コード例 #3
0
        public void When_Applying_A_New_Event()
        {
            var subject = new AggregateStub(Guid.NewGuid());
            var @event = new EventStubTypeA();

            subject.ApplyEventToAggregate(@event);

            var uncomittedEvents = subject.GetUncomittedEvents();
            Assert.IsTrue(subject.EventTypeAApplied);
            Assert.That(uncomittedEvents, Has.Count.EqualTo(1));
            Assert.That(uncomittedEvents.First(), Is.SameAs(@event));
        }
コード例 #4
0
        public void When_Loading_From_Event_History_And_Applying_New_Event()
        {
            var subject = new AggregateStub(Guid.NewGuid());
            var history = new List<EventBaseV1> { new EventStubTypeA(), new EventStubTypeB() };

            subject.LoadFromHistory(history);
            var newEvent = new EventStubTypeC();
            subject.ApplyEventToAggregate(newEvent);

            var uncomittedEvents = subject.GetUncomittedEvents();

            Assert.That(uncomittedEvents, Has.Count.EqualTo(1));
            Assert.That(uncomittedEvents.First(), Is.SameAs(newEvent));
            Assert.That(subject.EventTypeAApplied, Is.True);
            Assert.That(subject.EventTypeBApplied, Is.True);
            Assert.That(subject.EventTypeCApplied, Is.True);
        }