示例#1
0
        public void FetchOrAddRule_NullRuleResult_ReturnRule()
        {
            RuleResult ruleResult = GenerateRuleResult();

            using (ShimsContext.Create())
            {
                ShimResultsFileSarifMapper.FetchOrAddStandardsRuleResult = (_) =>
                {
                    return(new string[] { Standard });
                };

                Rule returnedRule = ResultsFileSarifMapper.FetchOrAddRule(null);
                Assert.IsNull(returnedRule);
            }
        }
示例#2
0
        public void FetchOrAddRule_RuleExists_ReturnRule()
        {
            RuleResult ruleResult = GenerateRuleResult();

            Rule sarifRule = GenerateRuleFromRuleResult(ruleResult);

            using (ShimsContext.Create())
            {
                ShimResultsFileSarifMapper.FetchOrAddStandardsRuleResult = (_) =>
                {
                    return(new string[] { Standard });
                };

                Rule returnedRule = ResultsFileSarifMapper.FetchOrAddRule(ruleResult);

                AssertRulesEqual(sarifRule, returnedRule);
            }
        }
示例#3
0
        public void FetchOrAddRule_NewRule_ReturnRule()
        {
            RuleResult ruleResult = GenerateRuleResult();

            using (ShimsContext.Create())
            {
                ShimResultsFileSarifMapper.FetchOrAddStandardsRuleResult = (_) =>
                {
                    return(new string[] { Standard });
                };

                Rule addedRule = GenerateRuleFromRuleResult(ruleResult);

                Rule returnedRule = ResultsFileSarifMapper.FetchOrAddRule(ruleResult);

                AssertRulesEqual(addedRule, returnedRule);

                Assert.IsTrue(ResultsFileSarifMapper.RuleList.ContainsKey(ruleResult.Rule.ToString()));
            }
        }