public override Task <bool> Execute(RecommendationTestInput input)
        {
            var directory = Path.GetDirectoryName(input.ProjectDefinition.ProjectPath);
            var result    = (Directory.GetFiles(directory, input.Test.Condition.FileName).Length == 1);

            return(Task.FromResult(result));
        }
Пример #2
0
        public override Task <bool> Execute(RecommendationTestInput input)
        {
            var propertyValue = input.ProjectDefinition.GetMSPropertyValue(input.Test.Condition.PropertyName);
            var result        = (propertyValue != null && input.Test.Condition.AllowedValues.Contains(propertyValue));

            return(Task.FromResult(result));
        }
Пример #3
0
        public async Task <RulesResult> EvaluateRules(ProjectDefinition projectDefinition, IList <RecommendationRuleItem> rules)
        {
            // If there are no rules the recipe must be invalid so don't include it.
            if (false == rules?.Any())
            {
                return(new RulesResult {
                    Include = false
                });
            }

            var availableTests = RecommendationTestFactory.LoadAvailableTests();
            var results        = new RulesResult {
                Include = true
            };

            foreach (var rule in rules)
            {
                var allTestPass = true;
                foreach (var test in rule.Tests)
                {
                    if (!availableTests.TryGetValue(test.Type, out var testInstance))
                    {
                        throw new InvalidRecipeDefinitionException($"Invalid test type [{test.Type}] found in rule.");
                    }

                    var input = new RecommendationTestInput
                    {
                        Test = test,
                        ProjectDefinition = projectDefinition,
                        Session           = _orchestratorSession
                    };
                    allTestPass &= await testInstance.Execute(input);

                    if (!allTestPass)
                    {
                        break;
                    }
                }

                results.Include &= ShouldInclude(rule.Effect, allTestPass);

                var effectOptions = GetEffectOptions(rule.Effect, allTestPass);

                if (effectOptions != null)
                {
                    if (effectOptions.PriorityAdjustment.HasValue)
                    {
                        results.PriorityAdjustment += effectOptions.PriorityAdjustment.Value;
                    }
                }
            }

            return(results);
        }
Пример #4
0
        public override Task <bool> Execute(RecommendationTestInput input)
        {
            var result = !string.IsNullOrEmpty(input.ProjectDefinition.GetPackageReferenceVersion(input.Test.Condition.NuGetPackageName));

            return(Task.FromResult(result));
        }
        public override Task <bool> Execute(RecommendationTestInput input)
        {
            var result = string.Equals(input.ProjectDefinition.SdkType, input.Test.Condition.Value, StringComparison.InvariantCultureIgnoreCase);

            return(Task.FromResult(result));
        }
Пример #6
0
        public override Task <bool> Execute(RecommendationTestInput input)
        {
            var result = !string.IsNullOrEmpty(input.ProjectDefinition.GetMSPropertyValue(input.Test.Condition.PropertyName));

            return(Task.FromResult(result));
        }
Пример #7
0
 /// <summary>
 /// Executes the test
 /// </summary>
 /// <param name="input"></param>
 /// <returns>True for successful test pass, otherwise false.</returns>
 public abstract Task <bool> Execute(RecommendationTestInput input);