Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        public void HandlerIsCalledWhenHandlerIsProtectedAndEventIsApplied()
        {
            var domainEvent = new EntityProtectedHandlerThatMeetsConventionEvent();
            var entity = new MyEntity(new Guid());
            entity.TurnTestModeOn();

            entity.Apply(domainEvent);

            Assert.IsTrue(entity.OnEntityProtectedHandlerThatMeetsConventionCalled);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public void HandlerIsCalledWhenHandlerIsProtectedAndEventIsApplied()
        {
            var domainEvent = new EntityProtectedHandlerThatMeetsConventionEvent();
            var entity      = new MyEntity(new Guid());

            entity.TurnTestModeOn();

            entity.Apply(domainEvent);

            Assert.IsTrue(entity.OnEntityProtectedHandlerThatMeetsConventionCalled);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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());
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }