private void CompileAndTest(string text, params string[] unusedParams) { AssertRuleCodeDiagnostics(NoUnusedParametersRule.Code, text, diags => { if (unusedParams.Any()) { var rule = new NoUnusedParametersRule(); string[] expectedMessages = unusedParams.Select(p => rule.GetMessage(p)).ToArray(); diags.Select(e => e.Message).Should().ContainInOrder(expectedMessages); } else { diags.Should().BeEmpty(); } }); }
private void CompileAndTest(string text, params string[] unusedParams) { using (new AssertionScope($"linter errors for this code:\n{text}\n")) { var errors = GetDiagnostics(NoUnusedParametersRule.Code, text); if (unusedParams.Any()) { var rule = new NoUnusedParametersRule(); string[] expectedMessages = unusedParams.Select(p => rule.GetMessage(p)).ToArray(); errors.Select(e => e.Message).Should().ContainInOrder(expectedMessages); } else { errors.Should().BeEmpty(); } } }
public void ParameterNameInFormattedMessage() { var ruleToTest = new NoUnusedParametersRule(); ruleToTest.GetMessage(nameof(ruleToTest)).Should().Be($"Parameter \"{nameof(ruleToTest)}\" is declared but never used."); }