Exemple #1
0
        public void MustReturnFalseIfTypeDoesNotImplementIMessageHandler()
        {
            var typeToMatch = typeof(ICommand);

            var argType = New.Common().Type
                          .WithImplementedInterfaces(typeToMatch)
                          .Creation;
            var closedGenericWithArgType = New.Common().Type
                                           .WithGenericTypeDef(typeof(IEnumerable <>))
                                           .WithGenericArguments(argType)
                                           .Creation;
            var type = New.Common().Type
                       .WithImplementedInterfaces(closedGenericWithArgType)
                       .Creation;

            var result = CqrsExtensions.IsValidMessageHandler(type, typeToMatch);

            Assert.False(result);
        }
Exemple #2
0
        public void MustReturnTrueIfNotGenericTypeAndImplementsIMessageHandlerWithMatchingTypeParam()
        {
            var typeToMatch = typeof(ICommand);

            var argType = New.Common().Type
                          .WithImplementedInterfaces(typeToMatch)
                          .Creation;
            var closedGenericWithArgType = New.Common().Type
                                           .WithGenericTypeDef(typeof(IMessageHandler <>))
                                           .WithGenericArguments(argType)
                                           .Creation;
            var type = New.Common().Type
                       .WithImplementedInterfaces(closedGenericWithArgType)
                       .Creation;

            var result = CqrsExtensions.IsValidMessageHandler(type, typeToMatch);

            Assert.True(result);
        }