public void RegisterHandlersAssemblyICommandHandlerTest()
        {
            var result    = CqrsExtensions.RegisterHandlersAssembly(typeof(ObjectCommandHandler));
            var assResult = (typeof(ICommandHandler <CreateObject>), typeof(ObjectCommandHandler)).GetType();

            Assert.Contains(assResult, result.Select(_ => _.GetType()));
        }
        public void RegisterHandlersAssemblyIQuerydHandlerTest()
        {
            var result    = CqrsExtensions.RegisterHandlersAssembly(typeof(ObjectCommandHandler));
            var assResult = (typeof(IQueryHandler <GetObjects, IEnumerable <CreateObject> >), typeof(ObjectQueryHandler)).GetType();
            var rre       = result.Select(_ => _.GetType()).Contains(assResult);

            Assert.Contains(assResult, result.Select(_ => _.GetType()));
        }
        public void GetDependenciesTest()
        {
            var result        = CqrsExtensions.GetDependencies(new Type[] { typeof(CreateObject) });
            var expetedResult = new List <(Type contract, Type concrete)>
            {
                (typeof(IQueryHandler <GetObjects, IEnumerable <CreateObject> >), typeof(ObjectQueryHandler)),
                (typeof(ICommandHandler <CreateObject>), typeof(ObjectCommandHandler))
            };
            var reponse = true;

            expetedResult.ForEach(_ => {
                if (!result.Contains(_))
                {
                    reponse = false;
                }
            });
            Assert.True(reponse);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }