Skip to content

Commit 79dc08e

Browse files
committed
refactor: more tests
1 parent 154ad45 commit 79dc08e

1 file changed

Lines changed: 87 additions & 1 deletion

File tree

QueryKit.IntegrationTests/Tests/DatabaseFilteringTests.cs

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,34 @@ public async Task can_filter_by_datetime_with_milliseconds()
276276
people[0].Id.Should().Be(fakePersonOne.Id);
277277
}
278278

279+
[Fact]
280+
public async Task can_filter_by_datetime_with_milliseconds_full_fractional()
281+
{
282+
// Arrange
283+
var testingServiceScope = new TestingServiceScope();
284+
var dateUtcNow = DateTime.UtcNow;
285+
var dateInMilliPast = dateUtcNow.AddMilliseconds(-100);
286+
var fakePersonOne = new FakeTestingPersonBuilder()
287+
.WithSpecificDateTime(dateUtcNow)
288+
.Build();
289+
var fakePersonTwo = new FakeTestingPersonBuilder()
290+
.WithSpecificDateTime(dateInMilliPast)
291+
.Build();
292+
await testingServiceScope.InsertAsync(fakePersonOne, fakePersonTwo);
293+
294+
var input = $"""SpecificDateTime == "{fakePersonOne.SpecificDateTime:o}" """;
295+
296+
// Act
297+
var queryablePeople = testingServiceScope.DbContext().People;
298+
299+
var appliedQueryable = queryablePeople.ApplyQueryKitFilter(input);
300+
var people = await appliedQueryable.ToListAsync();
301+
302+
// Assert
303+
people.Count.Should().Be(1);
304+
people[0].Id.Should().Be(fakePersonOne.Id);
305+
}
306+
279307
[Fact]
280308
public async Task can_filter_by_dateonly()
281309
{
@@ -843,7 +871,65 @@ public async Task can_filter_with_child_props_for_complex_property()
843871
var queryablePeople = testingServiceScope.DbContext().Recipes;
844872
var config = new QueryKitConfiguration(config =>
845873
{
846-
config.Property<Recipe>(x => x.CollectionEmail.Value);//.HasQueryName("email");
874+
config.Property<Recipe>(x => x.CollectionEmail.Value);
875+
});
876+
var appliedQueryable = queryablePeople.ApplyQueryKitFilter(input, config);
877+
var people = await appliedQueryable.ToListAsync();
878+
879+
// Assert
880+
people.Count.Should().Be(1);
881+
people[0].Id.Should().Be(fakePersonOne.Id);
882+
}
883+
884+
[Fact]
885+
public async Task can_filter_with_child_props_for_aliased_complex_property()
886+
{
887+
// Arrange
888+
var testingServiceScope = new TestingServiceScope();
889+
var faker = new Faker();
890+
var fakePersonOne = new FakeRecipeBuilder()
891+
.WithCollectionEmail(faker.Internet.Email())
892+
.Build();
893+
var fakePersonTwo = new FakeRecipeBuilder()
894+
.Build();
895+
await testingServiceScope.InsertAsync(fakePersonOne, fakePersonTwo);
896+
897+
var input = $"""email == "{fakePersonOne.CollectionEmail.Value}" """;
898+
899+
// Act
900+
var queryablePeople = testingServiceScope.DbContext().Recipes;
901+
var config = new QueryKitConfiguration(config =>
902+
{
903+
config.Property<Recipe>(x => x.CollectionEmail.Value).HasQueryName("email");
904+
});
905+
var appliedQueryable = queryablePeople.ApplyQueryKitFilter(input, config);
906+
var people = await appliedQueryable.ToListAsync();
907+
908+
// Assert
909+
people.Count.Should().Be(1);
910+
people[0].Id.Should().Be(fakePersonOne.Id);
911+
}
912+
913+
[Fact]
914+
public async Task can_filter_with_child_props_for_null_aliased_complex_property()
915+
{
916+
// Arrange
917+
var testingServiceScope = new TestingServiceScope();
918+
var faker = new Faker();
919+
var fakePersonOne = new FakeRecipeBuilder()
920+
.WithCollectionEmail(null)
921+
.Build();
922+
var fakePersonTwo = new FakeRecipeBuilder()
923+
.Build();
924+
await testingServiceScope.InsertAsync(fakePersonOne, fakePersonTwo);
925+
926+
var input = $"""email == null""";
927+
928+
// Act
929+
var queryablePeople = testingServiceScope.DbContext().Recipes;
930+
var config = new QueryKitConfiguration(config =>
931+
{
932+
config.Property<Recipe>(x => x.CollectionEmail.Value).HasQueryName("email");
847933
});
848934
var appliedQueryable = queryablePeople.ApplyQueryKitFilter(input, config);
849935
var people = await appliedQueryable.ToListAsync();

0 commit comments

Comments
 (0)