📄 core/tests/ScannerOptionsTests/IncludesProjectShould.cs
using Shouldly;
using Xunit;

namespace Cfa.Tests.ScannerOptionsTests;

public sealed class IncludesProjectShould
{
    [Theory]
    [InlineData("/repo/src/MyApp.csproj")]
    [InlineData("/repo/tests/MyApp.Tests.csproj")]
    public void IncludeEverythingWhenNoPatternsAreSpecified(string path)
    {
        // Arrange
        var options = new ScannerOptions();

        // Act
        var result = options.IncludesProject(path);

        // Assert
        result.ShouldBeTrue();
    }

    [Theory]
    [InlineData("/repo/tests/MyApp.Tests.csproj", false)]
    [InlineData(@"C:\repo\tests\MyApp.Tests.csproj", false)]
    [InlineData("/repo/Tests/MyApp.csproj", true)]
    public void MatchExclusionsAgainstTheProjectFilenameOnly(string path, bool expected)
    {
        // Arrange
        var options = new ScannerOptions { ExcludePatterns = [new("*Tests*")] };

        // Act
        var result = options.IncludesProject(path);

        // Assert
        result.ShouldBe(expected);
    }

    [Theory]
    [InlineData("/repo/MyApp.csproj", true)]
    [InlineData("/repo/Other.csproj", true)]
    [InlineData("/repo/Unrelated.csproj", false)]
    [InlineData("/repo/MyApp.Tests.csproj", false)]
    [InlineData("/repo/MyApp.Specs.csproj", false)]
    public void AcceptAnyIncludeButLetExclusionsWin(string path, bool expected)
    {
        // Arrange
        var options = new ScannerOptions
        {
            IncludePatterns = [new("MyApp*"), new("Other*")],
            ExcludePatterns = [new("*Tests*"), new("*Specs*")],
        };

        // Act
        var result = options.IncludesProject(path);

        // Assert
        result.ShouldBe(expected);
    }
}