diff --git a/.github/workflows/querykit-unit-tests.yaml b/.github/workflows/querykit-unit-tests.yaml index dfc7de6..fbfef90 100644 --- a/.github/workflows/querykit-unit-tests.yaml +++ b/.github/workflows/querykit-unit-tests.yaml @@ -10,7 +10,10 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: 10.0.x + # 6.0.x runs QueryKit.Net6Tests on the .NET 6 runtime + dotnet-version: | + 6.0.x + 10.0.x - name: Install dependencies run: dotnet restore @@ -19,3 +22,6 @@ jobs: - name: Test working-directory: QueryKit.UnitTests run: dotnet test --no-restore --configuration Release --verbosity minimal + - name: Test on .NET 6 + working-directory: QueryKit.Net6Tests + run: dotnet test --configuration Release --verbosity minimal diff --git a/CLAUDE.md b/CLAUDE.md index 9f99b56..11e82fd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -21,6 +21,7 @@ QueryKit is a .NET library for parsing and applying filtering and sorting operat - **Test Projects**: - `/QueryKit.UnitTests/` - Unit tests using xUnit - `/QueryKit.IntegrationTests/` - Integration tests with Entity Framework and PostgreSQL via Testcontainers + - `/QueryKit.Net6Tests/` - Tests for the net6.0 build on the .NET 6 runtime. It is not in QueryKit.sln, because it needs the .NET 6 runtime - `/QueryKit.WebApiTestProject/` - Test web API for integration scenarios - `/SharedTestingHelper/` - Shared test utilities and data builders @@ -40,6 +41,7 @@ dotnet test # Run specific test project dotnet test QueryKit.UnitTests/ dotnet test QueryKit.IntegrationTests/ +dotnet test QueryKit.Net6Tests/ # needs the .NET 6 runtime # Run tests with coverage dotnet test --collect:"XPlat Code Coverage" diff --git a/QueryKit.Net6Tests/QueryKit.Net6Tests.csproj b/QueryKit.Net6Tests/QueryKit.Net6Tests.csproj new file mode 100644 index 0000000..1216e0c --- /dev/null +++ b/QueryKit.Net6Tests/QueryKit.Net6Tests.csproj @@ -0,0 +1,29 @@ + + + + + net6.0 + enable + enable + true + false + + false + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/QueryKit.Net6Tests/TimeOnlyFilterTests.cs b/QueryKit.Net6Tests/TimeOnlyFilterTests.cs new file mode 100644 index 0000000..d22da77 --- /dev/null +++ b/QueryKit.Net6Tests/TimeOnlyFilterTests.cs @@ -0,0 +1,47 @@ +namespace QueryKit.Net6Tests; + +using FluentAssertions; + +public class TimeOnlyFilterTests +{ + private class Shift + { + public string Name { get; set; } = ""; + public TimeOnly? Start { get; set; } + } + + [Fact] + public void runs_on_the_net6_runtime() + { + Environment.Version.Major.Should().Be(6); + } + + // The TimeOnly constructor with microseconds needs .NET 7. On net6.0 the value is a constant. + [Fact] + public void time_only_value_filters_on_net6() + { + var shifts = new[] + { + new Shift { Name = "early", Start = new TimeOnly(8, 30) }, + new Shift { Name = "late", Start = new TimeOnly(9, 0) }, + }; + + var result = shifts.AsQueryable().ApplyQueryKitFilter("Start == \"08:30:00\"").ToList(); + + result.Select(x => x.Name).Should().Equal("early"); + } + + [Fact] + public void time_only_value_keeps_its_fraction_on_net6() + { + var shifts = new[] + { + new Shift { Name = "whole", Start = new TimeOnly(8, 30) }, + new Shift { Name = "fraction", Start = new TimeOnly(8, 30, 0, 500) }, + }; + + var result = shifts.AsQueryable().ApplyQueryKitFilter("Start == \"08:30:00.5\"").ToList(); + + result.Select(x => x.Name).Should().Equal("fraction"); + } +} diff --git a/QueryKit.Net6Tests/Usings.cs b/QueryKit.Net6Tests/Usings.cs new file mode 100644 index 0000000..c802f44 --- /dev/null +++ b/QueryKit.Net6Tests/Usings.cs @@ -0,0 +1 @@ +global using Xunit;