Exemple #1
0
        public void AddServiceCertificateCommand_HttpVerb_Post()
        {
            _mockQueryManager.Setup(
                t =>
                t.MakeASyncRequest(It.IsAny <ServiceManagementRequest>(), It.IsAny <ServiceManager.AsyncResponseParser>(),
                                   It.IsAny <ServiceManager.AsyncResponseException>()));

            _command.SitAndWait.Set();
            _command.Execute();

            _mockQueryManager.Verify(
                t =>
                t.MakeASyncRequest(It.Is <ServiceManagementRequest>(tRequest => tRequest.HttpVerb == "POST"), It.IsAny <ServiceManager.AsyncResponseParser>(),
                                   It.IsAny <ServiceManager.AsyncResponseException>()), Times.Once());
        }
        public void DeleteDeploymentCommand_HttpVerb_Delete()
        {
            _mockQueryManager.Setup(
                t =>
                t.MakeASyncRequest(It.IsAny <ServiceManagementRequest>(), It.IsAny <ServiceManager.AsyncResponseParser>(),
                                   It.IsAny <ServiceManager.AsyncResponseException>()));

            _command.SitAndWait.Set();
            _command.Execute();

            _mockQueryManager.Verify(
                t =>
                t.MakeASyncRequest(It.Is <ServiceManagementRequest>(tRequest => tRequest.HttpVerb == "DELETE"), It.IsAny <ServiceManager.AsyncResponseParser>(),
                                   It.IsAny <ServiceManager.AsyncResponseException>()), Times.Once());
        }
Exemple #3
0
        public void Service_Execute_ReturnsEmpty()
        {
            var console       = new TestConsole(_output, "userPassword");
            var command       = new ServiceCommand(_helpContextService.Object, console, LoggerMock.GetLogger <ServiceCommand>().Object);
            var resultMessage = command.Execute();

            Assert.Equal("", resultMessage);
        }
        public void ServiceCommand_Constructor_With_Sync_Method_Args_Contains_Correct_Errors_On_Failure()
        {
            var command = new ServiceCommand <Person>(
                executeMethod: () => new Person(),
                getBusinessRulesMethod: () => new[] { new FalseRule1() }
                );

            command.Execute().Errors.First().ErrorMessage.ShouldBe("FalseRule1 failed validation");
        }
        public async Task ServiceCommand_Composition_11()
        {
            var command = new ServiceCommand
                          (
                executeAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("4");
        }
        public async Task ServiceCommand_Composition_12()
        {
            var command = new ServiceCommand
                          (
                executeAsyncMethod,
                getBusinessRulesAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("34");
        }
        public async Task ServiceCommand_Composition_7()
        {
            var command = new ServiceCommand
                          (
                executeMethod,
                getErrorsMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("24");
        }
        public async Task ServiceCommand_Composition_4()
        {
            var command = new ServiceCommand
                          (
                initializationAsyncMethod,
                executeAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("14");
        }
Exemple #9
0
        public async Task ServiceCommandOfT_Composition_10()
        {
            var command = new ServiceCommand <Person>
                          (
                executeMethod,
                getBusinessRulesMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("34");
        }
Exemple #10
0
        public async Task ServiceCommandOfT_Composition_8()
        {
            var command = new ServiceCommand <Person>
                          (
                executeAsyncMethod,
                getErrorsAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("24");
        }
Exemple #11
0
        public async Task ServiceCommandOfT_Composition_3()
        {
            var command = new ServiceCommand <Person>
                          (
                initializationMethod,
                executeMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("14");
        }
Exemple #12
0
        public async Task ServiceCommandOfT_Composition_13()
        {
            var command = new ServiceCommand <Person>
                          (
                initializationAsyncMethod,
                executeAsyncMethod,
                getBusinessRulesAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("134");
        }
        public async Task ServiceCommand_Constructor_With_Async_And_Sync_Method_Args_Contains_Correct_Errors_On_Failure()
        {
            var command = new ServiceCommand <Person>(
                executeMethod: () => new Person(),
                executeAsyncMethod: () => Task.Run(() => new Person()),
                getBusinessRulesMethod: () => new[] { new FalseRule1() },
                getBusinessRulesAsyncMethod: () => Task.Run <IEnumerable <IRule> >(() => new [] { new FalseRule2() })
                );

            command.Execute().Errors.First().ErrorMessage.ShouldBe("FalseRule1 failed validation");
            var result = await command.ExecuteAsync();

            result.Errors.First().ErrorMessage.ShouldBe("FalseRule2 failed validation");
        }
Exemple #14
0
        public virtual string ProcessMessage(InputMessage message)
        {
            if (message == null)
            {
                return(GetErrorMessage("Message is null"));
            }

            var outputMessage = _command?.Execute(message);

            if (outputMessage == null)
            {
                return(GetErrorMessage("Unknown command"));
            }

            return(_converter?.Serialize(outputMessage));
        }
        public async Task ServiceCommand_Composition_1()
        {
            var command = new ServiceCommand
                          (
                initializationMethod,
                initializationAsyncMethod,
                getErrorsMethod,
                getErrorsAsyncMethod,
                executeMethod,
                executeAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("124124");
        }
Exemple #16
0
        private static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Not enough arguments !");
                return;
            }

            Config.Model = args[0].ToLower().UppercaseFirst();
            var command = "";

            if (args.Length > 1)
            {
                command = args[1].ToLower();
            }

            if (args.Length > 2)
            {
                Config.Area = args[2].ToLower().UppercaseFirst();
            }

            Config.ModelsPath     = Environment.CurrentDirectory + "\\";
            Config.ViewModelsPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.FullName + "\\ViewModels\\";
            Config.RepositoryPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.FullName + "\\Repository\\";
            Config.ServicePath    = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.FullName + "\\Service\\";

            if (string.IsNullOrEmpty(Config.Area))
            {
                Config.ControllerPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Controllers\\";
                Config.ViewsPath      = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Views\\" + Config.Model + "\\";
            }
            else
            {
                Config.ControllerPath = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Areas\\" + Config.Area + "\\Controllers\\";
                Config.ViewsPath      = new System.IO.DirectoryInfo(Config.ModelsPath).Parent.Parent.Parent.FullName + "\\Portal.Web\\Areas\\" + Config.Area + "\\Views\\" + Config.Model + "\\";
            }

            var viewsDir = new System.IO.DirectoryInfo(Config.ViewsPath);

            if (!viewsDir.Exists)
            {
                viewsDir.Create();
            }

            Config.PropertyNames        = ClassHelper.GetPropertyNames(Config.ModelsPath + Config.Model + ".cs");
            Config.PropertyTypes        = ClassHelper.GetPropertyTypes(Config.ModelsPath + Config.Model + ".cs");
            Config.PropertyDeclarations = ClassHelper.GetPropertyDeclarations(Config.ModelsPath + Config.Model + ".cs");

            switch (command)
            {
            case "sr":
            case "service":
                var iserviceCommand = new IServiceCommand();
                var serviceCommand  = new ServiceCommand();
                iserviceCommand.Execute();
                serviceCommand.Execute();
                break;

            case "rp":
            case "repository":
                var irepositoryCommand = new IRepositoryCommand();
                var repositoryCommand  = new RepositoryCommand();
                irepositoryCommand.Execute();
                repositoryCommand.Execute();
                break;

            case "vm":
            case "viewmodel":
                var viewModelCommand = new ViewModelCommand();
                viewModelCommand.Execute();
                break;

            case "ad":
            case "addmodel":
                var addModel = new AddModelCommand();
                addModel.Execute();
                break;

            case "vi":
            case "views":
                var indexCommand   = new IndexCommand();
                var createCommand  = new CreateCommand();
                var editCommand    = new EditCommand();
                var deleteCommand  = new DeleteCommand();
                var detailsCommand = new DetailsCommand();

                indexCommand.Execute();
                createCommand.Execute();
                editCommand.Execute();
                deleteCommand.Execute();
                detailsCommand.Execute();

                break;

            case "cr":
            case "controller":
                var controllerCommand = new ControllerCommand();
                controllerCommand.Execute();
                break;

            case "go":
            default:
                var goCommand = new GoCommand();
                goCommand.Execute();


                break;
            }
        }
Exemple #17
0
 public override OutputMessage Execute(InputMessage message)
 {
     return(_command?.Execute(message));
 }