Exemple #1
0
        public async Task ResetOptionSettingValue_String()
        {
            var interactiveServices = new TestToolInteractiveServiceImpl(new List <string>
            {
                "<reset>"
            });
            var consoleUtilities = new ConsoleUtilities(interactiveServices, _directoryManager);

            var engine = await BuildRecommendationEngine("WebAppNoDockerFile");

            var recommendations = await engine.ComputeRecommendations();

            var fargateRecommendation = recommendations.First(r => r.Recipe.Id == Constants.ASPNET_CORE_ASPNET_CORE_FARGATE_RECIPE_ID);

            fargateRecommendation.AddReplacementToken("{StackName}", "MyAppStack");

            var ecsServiceNameOptionSetting = fargateRecommendation.Recipe.OptionSettings.First(optionSetting => optionSetting.Id.Equals("ECSServiceName"));

            var originalDefaultValue = fargateRecommendation.GetOptionSettingDefaultValue <string>(ecsServiceNameOptionSetting);

            ecsServiceNameOptionSetting.SetValueOverride("TestService");

            Assert.Equal("TestService", fargateRecommendation.GetOptionSettingValue <string>(ecsServiceNameOptionSetting));

            ecsServiceNameOptionSetting.SetValueOverride(consoleUtilities.AskUserForValue("Title", "TestService", true, originalDefaultValue));

            Assert.Equal(originalDefaultValue, fargateRecommendation.GetOptionSettingValue <string>(ecsServiceNameOptionSetting));
        }
Exemple #2
0
        public async Task ResetOptionSettingValue_Int()
        {
            var interactiveServices = new TestToolInteractiveServiceImpl(new List <string>
            {
                "<reset>"
            });

            var consoleUtilities = new ConsoleUtilities(interactiveServices, _directoryManager);

            var engine = await BuildRecommendationEngine("WebAppNoDockerFile");

            var recommendations = await engine.ComputeRecommendations();

            var fargateRecommendation     = recommendations.First(r => r.Recipe.Id == Constants.ASPNET_CORE_ASPNET_CORE_FARGATE_RECIPE_ID);
            var desiredCountOptionSetting = fargateRecommendation.Recipe.OptionSettings.First(optionSetting => optionSetting.Id.Equals("DesiredCount"));

            var originalDefaultValue = fargateRecommendation.GetOptionSettingDefaultValue <int>(desiredCountOptionSetting);

            desiredCountOptionSetting.SetValueOverride(2);

            Assert.Equal(2, fargateRecommendation.GetOptionSettingValue <int>(desiredCountOptionSetting));

            desiredCountOptionSetting.SetValueOverride(consoleUtilities.AskUserForValue("Title", "2", true, originalDefaultValue.ToString()));

            Assert.Equal(originalDefaultValue, fargateRecommendation.GetOptionSettingValue <int>(desiredCountOptionSetting));
        }
        public async Task ClearOptionSettingValue_String()
        {
            var interactiveServices = new TestToolInteractiveServiceImpl(new List <string>
            {
                "<reset>"
            });
            var consoleUtilities = new ConsoleUtilities(interactiveServices);
            var projectPath      = SystemIOUtilities.ResolvePath("WebAppNoDockerFile");
            var engine           = new RecommendationEngine(new[] { RecipeLocator.FindRecipeDefinitionsPath() }, new Orchestrator.OrchestratorSession());
            var recommendations  = await engine.ComputeRecommendations(projectPath, new Dictionary <string, string>());

            var fargateRecommendation       = recommendations.First(r => r.Recipe.Id == Constants.ASPNET_CORE_ASPNET_CORE_FARGATE_RECIPE_ID);
            var ecsServiceNameOptionSetting = fargateRecommendation.Recipe.OptionSettings.First(optionSetting => optionSetting.Id.Equals("ECSServiceName"));

            var originalDefaultValue = fargateRecommendation.GetOptionSettingDefaultValue <string>(ecsServiceNameOptionSetting);

            ecsServiceNameOptionSetting.SetValueOverride("TestService");

            Assert.Equal("TestService", fargateRecommendation.GetOptionSettingValue <string>(ecsServiceNameOptionSetting));

            ecsServiceNameOptionSetting.SetValueOverride(consoleUtilities.AskUserForValue("Title", "TestService", true, originalDefaultValue));

            Assert.Equal(originalDefaultValue, fargateRecommendation.GetOptionSettingValue <string>(ecsServiceNameOptionSetting));
        }