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); } }
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); } }
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())); } }