Ejemplo n.º 1
0
        public void Should_FindTwoHandlers_When_InitialisingWithMultipleAssembliesContainingOneHandlerEach()
        {
            // Arrange
            var domainEventHandlersProvider = new DomainEventHandlersProvider();

            // Act
            domainEventHandlersProvider.Init(new List <Assembly> {
                typeof(WhateverDomainEventHandler).Assembly, typeof(DummyDomainEventHandler).Assembly
            });

            // Assert
            var whateverHandlersTypes = domainEventHandlersProvider.GetHandlersTypes <WhateverDomainEvent>();

            Assert.IsNotNull(whateverHandlersTypes);
            Assert.AreEqual(1, whateverHandlersTypes.Count());
            var whateverHandlerType = whateverHandlersTypes.ElementAt(0);

            Assert.AreEqual(typeof(WhateverDomainEventHandler).FullName, whateverHandlerType.FullName);

            var dummyHandlersTypes = domainEventHandlersProvider.GetHandlersTypes <DummyDomainEvent>();

            Assert.IsNotNull(dummyHandlersTypes);
            Assert.AreEqual(1, dummyHandlersTypes.Count());
            var dummyHandlerType = dummyHandlersTypes.ElementAt(0);

            Assert.AreEqual(typeof(DummyDomainEventHandler).FullName, dummyHandlerType.FullName);
        }
Ejemplo n.º 2
0
        public void Should_FindOneHandler_When_InitialisingWithMultipleAssembliesContainingOneHandler()
        {
            // Arrange
            var domainEventHandlersProvider = new DomainEventHandlersProvider();

            // Act
            domainEventHandlersProvider.Init(new List <Assembly> {
                typeof(AggregateRoot <>).Assembly, typeof(DummyDomainEventHandler).Assembly
            });

            // Assert
            var handlersTypes = domainEventHandlersProvider.GetHandlersTypes <DummyDomainEvent>();

            Assert.IsNotNull(handlersTypes);
            Assert.AreEqual(1, handlersTypes.Count());
            var handlerType = handlersTypes.ElementAt(0);

            Assert.AreEqual(typeof(DummyDomainEventHandler).FullName, handlerType.FullName);
        }
Ejemplo n.º 3
0
        public void Should_NotThrowException_When_TypeIsIDomainEvent()
        {
            // Arrange
            var domainEventHandlersProvider = new DomainEventHandlersProvider();

            // Act
            domainEventHandlersProvider.Init(new List <Assembly> {
                typeof(WhateverDomainEventHandler).Assembly
            });

            // Assert
            var handlersTypes = domainEventHandlersProvider.GetHandlersTypes <WhateverDomainEvent>();

            Assert.IsNotNull(handlersTypes);
            Assert.AreEqual(1, handlersTypes.Count());
            var handlerType = handlersTypes.ElementAt(0);

            Assert.AreEqual(typeof(WhateverDomainEventHandler).FullName, handlerType.FullName);
        }
Ejemplo n.º 4
0
        public void Should_ThrowException_When_TypeIsNull()
        {
            // Arrange
            var domainEventHandlersProvider = new DomainEventHandlersProvider();

            // Act
            domainEventHandlersProvider.Init(new List <Assembly> {
                typeof(WhateverDomainEventHandler).Assembly
            });

            // Assert
            try
            {
                domainEventHandlersProvider.GetHandlersTypes(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
            }
        }