Пример #1
0
            public void MethodMustHaveVoidReturn()
            {
                var attribute = new HandleByAttributeAttribute();
                var ex        = Assert.Throws <MappingException>(() => attribute.GetHandleMethods(typeof(FakeAggregateWithReturn), new Mock <IServiceProvider>().Object));

                Assert.Equal(Exceptions.HandleMethodMustHaveVoidReturn.FormatWith(typeof(FakeAggregateWithReturn), "OnFakeCommand"), ex.Message);
            }
Пример #2
0
            public void MethodMustHaveCommandAsFirstParameter()
            {
                var attribute = new HandleByAttributeAttribute();
                var ex        = Assert.Throws <MappingException>(() => attribute.GetHandleMethods(typeof(FakeAggregateWithNoParameters), new Mock <IServiceProvider>().Object));

                Assert.Equal(Exceptions.HandleMethodInvalidParameters.FormatWith(typeof(Command), typeof(FakeAggregateWithNoParameters), "OnFakeCommand"), ex.Message);
            }
            public void MethodMustHaveEventAsFirstParameter()
            {
                var attribute = new HandleByAttributeAttribute();
                var ex = Assert.Throws<MappingException>(() => attribute.GetHandleMethods(typeof(FakeHandlerWithNoParameters), new Mock<IServiceProvider>().Object));

                Assert.Equal(Exceptions.HandleMethodInvalidParameters.FormatWith(typeof(Event), typeof(FakeHandlerWithNoParameters), "OnFakeEvent"), ex.Message);
            }
Пример #4
0
            public void DoNotUseConventionBasedMapping()
            {
                var attribute     = new HandleByAttributeAttribute();
                var handleMethods = attribute.GetHandleMethods(typeof(FakeAggregateWithNoAttribute), new Mock <IServiceProvider>().Object);

                Assert.Equal(0, handleMethods.Count);
            }
            public void MethodMustHaveVoidReturn()
            {
                var attribute = new HandleByAttributeAttribute();
                var ex = Assert.Throws<MappingException>(() => attribute.GetHandleMethods(typeof(FakeHandlerWithReturn), new Mock<IServiceProvider>().Object));

                Assert.Equal(Exceptions.HandleMethodMustHaveVoidReturn.FormatWith(typeof(FakeHandlerWithReturn), "OnFakeEvent"), ex.Message);
            }
            public void DoNotUseConventionBasedMapping()
            {
                var attribute = new HandleByAttributeAttribute();
                var handleMethods = attribute.GetHandleMethods(typeof(FakeHandlerWithNoAttribute), new Mock<IServiceProvider>().Object);

                Assert.Equal(0, handleMethods.Count);
            }
Пример #7
0
            public void PublicMethodsAreIncluded()
            {
                var attribute = new HandleByAttributeAttribute {
                    PublicOnly = false
                };
                var handleMethods = attribute.GetHandleMethods(typeof(FakeAggregate), new Mock <IServiceProvider>().Object);

                Assert.Equal(1, handleMethods.Count);
            }
            public void NonPublicMethodsAreExcluded()
            {
                var attribute = new HandleByAttributeAttribute {
                    PublicOnly = true
                };
                var handleMethods = attribute.GetHandleMethods(typeof(FakeHandler), new Mock <IServiceProvider>().Object);

                Assert.Equal(0, handleMethods.Count);
            }
Пример #9
0
            public void CannotOverloadHandleMethods()
            {
                var serviceProvider = new Mock <IServiceProvider>();
                var attribute       = new HandleByAttributeAttribute {
                    PublicOnly = false
                };
                var expectedException = new MappingException(Exceptions.HandleMethodOverloaded.FormatWith(typeof(FakeAggregate), "Void Handle(FakeCommand, FakeService, FakeService)"));

                serviceProvider.Setup(mock => mock.GetService(typeof(FakeService))).Returns(null);

                var actualException = Assert.Throws <MappingException>(() => attribute.GetHandleMethods(typeof(FakeAggregate), serviceProvider.Object));

                Assert.Equal(expectedException.Message, actualException.Message);
            }
            public void PublicMethodsAreIncluded()
            {
                var attribute = new HandleByAttributeAttribute { PublicOnly = false };
                var handleMethods = attribute.GetHandleMethods(typeof(FakeHandler), new Mock<IServiceProvider>().Object);

                Assert.Equal(1, handleMethods.Count);
            }
            public void CannotOverloadHandleMethods()
            {
                var serviceProvider = new Mock<IServiceProvider>();
                var attribute = new HandleByAttributeAttribute { PublicOnly = false };
                var expectedException = new MappingException(Exceptions.HandleMethodOverloaded.FormatWith(typeof(FakeHandler), "Void Handle(FakeEvent, FakeService, FakeService)"));

                serviceProvider.Setup(mock => mock.GetService(typeof(FakeService))).Returns(null);

                var actualException = Assert.Throws<MappingException>(() => attribute.GetHandleMethods(typeof(FakeHandler), serviceProvider.Object));

                Assert.Equal(expectedException.Message, actualException.Message);
            }
            public void NonPublicMethodsAreExcluded()
            {
                var attribute = new HandleByAttributeAttribute { PublicOnly = true };
                var handleMethods = attribute.GetHandleMethods(typeof(FakeAggregate), new Mock<IServiceProvider>().Object);

                Assert.Equal(0, handleMethods.Count);
            }