public void If_test_mode_is_off_an_null_reference_exception_is_thrown_when_an_event_is_applied() { var entityId = Guid.NewGuid(); var entity = new MyEntity(entityId); entity.TurnTestModeOff(); entity.Apply(new MyEntityCreatedEvent()); }
public void HandlerIsCalledWhenHandlerIsProtectedAndEventIsApplied() { var domainEvent = new EntityProtectedHandlerThatMeetsConventionEvent(); var entity = new MyEntity(new Guid()); entity.TurnTestModeOn(); entity.Apply(domainEvent); Assert.IsTrue(entity.OnEntityProtectedHandlerThatMeetsConventionCalled); }
public void EntityId_is_set_on_applied_events() { var entityId = Guid.NewGuid(); var entity = new MyEntity(entityId); entity.TurnTestModeOn(); entity.Apply(new MyEntityCreatedEvent()); Assert.AreEqual(entity.UncommittedEvents[0].EntityId, entityId); }
public void When_an_event_is_applied_to_the_entity_the_event_is_applied_to_the_aggregate_root() { var entityId = Guid.NewGuid(); var entity = new MyEntity(entityId); entity.AggregateRoot = new MyAggregateRoot(); entity.TurnTestModeOn(); entity.Apply(new MyEntityCreatedEvent()); Assert.AreEqual(entity.UncommittedEvents[0].EntityId, entityId); }
public void When_an_event_is_applied_to_the_entity_the_event_is_added_to_the_uncommittedevents() { var entityId = Guid.NewGuid(); var entity = new MyEntity(entityId); entity.AggregateRoot = new MyAggregateRoot(); entity.TurnTestModeOn(); var entityCreatedEvent = new MyEntityCreatedEvent(); entity.Apply(entityCreatedEvent); Assert.AreSame(entity.UncommittedEvents[0], entityCreatedEvent); }