public void EventsAreSortedBySequenceBeforeBeingAppliedToTheAggregateRoot() { var aggregateRoot = new MyAggregateRoot(); var domainEvents = new List <AggregateRootHandlerThatMeetsConventionEvent> { new AggregateRootHandlerThatMeetsConventionEvent { Sequence = 5 }, new AggregateRootHandlerThatMeetsConventionEvent { Sequence = 1 }, new AggregateRootHandlerThatMeetsConventionEvent { Sequence = 100 }, new AggregateRootHandlerThatMeetsConventionEvent { Sequence = 2 } }; aggregateRoot.LoadFromHistoricalEvents(domainEvents.ToArray()); Assert.AreEqual(1, aggregateRoot.EventIds[0]); Assert.AreEqual(2, aggregateRoot.EventIds[1]); Assert.AreEqual(5, aggregateRoot.EventIds[2]); Assert.AreEqual(100, aggregateRoot.EventIds[3]); }
public void HandlerIsCalledWhenHandlerIsProtectedAndEventIsApplied() { var domainEvent = new AggregateRootProtectedHandlerThatMeetsConventionEvent(); var aggregateRoot = new MyAggregateRoot(); aggregateRoot.Apply(domainEvent); Assert.IsTrue(aggregateRoot.OnAggregateRootProtectedHandlerThatMeetsConventionCalled); }
public void WhenRegisterEntityIsCalledEntityAggegrateRootIsAssigned() { var aggregateRoot = new MyAggregateRoot(); var entity = new MyEntity(); aggregateRoot.RegisterEntity(entity); Assert.AreSame(aggregateRoot, entity.AggregateRoot); }
public void HandlerIsCalledWhenHandlerIsProtectedAndEventIsApplied() { var domainEvent = new AggregateRootProtectedHandlerThatMeetsConventionEvent(); var aggregateRoot = new MyAggregateRoot(); aggregateRoot.Apply(domainEvent); Assert.IsTrue(aggregateRoot.OnAggregateRootProtectedHandlerThatMeetsConventionCalled); }
public void WhenRegisterEntityIsCalledEntityAggegrateRootIsAssigned() { var aggregateRoot = new MyAggregateRoot(); var entity = new MyEntity(); aggregateRoot.RegisterEntity(entity); Assert.AreSame(aggregateRoot, entity.AggregateRoot); }
public void EventsAreSortedBySequenceBeforeBeingAppliedToTheAggregateRoot() { var aggregateRoot = new MyAggregateRoot(); var domainEvents = new List<AggregateRootHandlerThatMeetsConventionEvent> { new AggregateRootHandlerThatMeetsConventionEvent {Sequence = 5}, new AggregateRootHandlerThatMeetsConventionEvent {Sequence = 1}, new AggregateRootHandlerThatMeetsConventionEvent {Sequence = 100}, new AggregateRootHandlerThatMeetsConventionEvent {Sequence = 2} }; aggregateRoot.LoadFromHistoricalEvents(domainEvents.ToArray()); Assert.AreEqual(1, aggregateRoot.EventIds[0]); Assert.AreEqual(2, aggregateRoot.EventIds[1]); Assert.AreEqual(5, aggregateRoot.EventIds[2]); Assert.AreEqual(100, aggregateRoot.EventIds[3]); }
public void WhenEventModifierIsSetModificationsAreApplied() { // Arrange var fakeModification = new FakeModification { ModifyValueTo = "Yes we can" }; var aggregateRoot = new MyAggregateRoot(); var domainEvent = new EventForModificationTestEvent(); EventModifier.Modification = fakeModification; // Act aggregateRoot.Apply(domainEvent); // Assert Assert.AreEqual(domainEvent.ModifiedValue, fakeModification.ModifyValueTo); // Teardown EventModifier.Modification = null; }
public void WhenEventModifierIsSetModificationsAreApplied() { // Arrange var fakeModification = new FakeModification { ModifyValueTo = "Yes we can" }; var aggregateRoot = new MyAggregateRoot(); var domainEvent = new EventForModificationTestEvent(); EventModifier.Modification = fakeModification; // Act aggregateRoot.Apply(domainEvent); // Assert Assert.AreEqual(domainEvent.ModifiedValue, fakeModification.ModifyValueTo); // Teardown EventModifier.Modification = null; }