using FluentAssertions; using StellaOps.TestKit; using System; using Xunit; namespace StellaOps.AirGap.Policy.Analyzers.Tests; public sealed partial class PolicyAnalyzerRoslynTests { [Trait("Category", TestCategories.Unit)] [Fact] public async Task NoDiagnostic_InTestAssemblyAsync() { const string source = """ using System.Net.Http; namespace Sample.App.Tests; public sealed class DemoTests { public void TestMethod() { var client = new HttpClient(); } } """; var diagnostics = await AnalyzeAsync(source, assemblyName: "Sample.App.Tests"); diagnostics.Should().NotContain(d => d.Id == HttpClientUsageAnalyzer.DiagnosticId, "Test assemblies should be exempt from diagnostic"); } [Trait("Category", TestCategories.Unit)] [Fact] public async Task NoDiagnostic_InPolicyAssemblyAsync() { const string source = """ using System.Net.Http; namespace StellaOps.AirGap.Policy.Internal; internal static class Loopback { public static HttpClient Create() => new HttpClient(); } """; var diagnostics = await AnalyzeAsync(source, assemblyName: "StellaOps.AirGap.Policy"); diagnostics.Should().NotContain(d => d.Id == HttpClientUsageAnalyzer.DiagnosticId, "Policy assembly itself should be exempt"); } }