Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/querykit-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand Down
29 changes: 29 additions & 0 deletions QueryKit.Net6Tests/QueryKit.Net6Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<!-- Runs the net6.0 build of QueryKit on the .NET 6 runtime. This project is not in QueryKit.sln,
because it needs the .NET 6 runtime. CI installs that runtime, see querykit-unit-tests.yaml. -->
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>true</WarningsAsErrors>
<CheckEolTargetFramework>false</CheckEolTargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\QueryKit\QueryKit.csproj" />
</ItemGroup>

</Project>
47 changes: 47 additions & 0 deletions QueryKit.Net6Tests/TimeOnlyFilterTests.cs
Original file line number Diff line number Diff line change
@@ -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");
}
}
1 change: 1 addition & 0 deletions QueryKit.Net6Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
Loading