from pathlib import Path from scripts.adapters.dotnet import parse_dotnet_build_output _FIXTURES = Path(__file__).parent / "fixtures" def test_parses_scs_as_high(): txt = (_FIXTURES / "dotnet_build_sample.txt").read_text() findings = parse_dotnet_build_output(txt, repo_root="/repo") by_rule = {f.rule_id: f for f in findings} assert "SCS0018" in by_rule assert by_rule["SCS0018"].severity == "high" assert by_rule["SCS0018"].file == "src/Program.cs" assert by_rule["SCS0018"].line == 22 def test_parses_cs_error_as_medium(): txt = (_FIXTURES / "dotnet_build_sample.txt").read_text() findings = parse_dotnet_build_output(txt, repo_root="/repo") by_rule = {f.rule_id: f for f in findings} assert by_rule["CS8602"].severity == "medium" def test_parses_ca_warning_as_low(): txt = (_FIXTURES / "dotnet_build_sample.txt").read_text() findings = parse_dotnet_build_output(txt, repo_root="/repo") by_rule = {f.rule_id: f for f in findings} assert by_rule["CA1834"].severity == "low" def test_handles_empty(): assert parse_dotnet_build_output("", repo_root="/repo") == []