-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffb6366
commit 915c87b
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace Gridify.Tests.IssueTests; | ||
|
||
public class Issue155Tests | ||
{ | ||
[Fact] | ||
public void ComparingFiledAWithFieldB_ShouldReturnTheCorrectResult() | ||
{ | ||
// arrange | ||
List<Item> items = | ||
[ | ||
new Item("Item1", [new TimeSchedule(1, 2), new TimeSchedule(2, 3)]), | ||
new Item("Item2", [new TimeSchedule(1, 4), new TimeSchedule(4, 3)]), | ||
new Item("Item3", [new TimeSchedule(3, 2), new TimeSchedule(2, 3)]), | ||
]; | ||
var expected = items.AsQueryable().Where(x => x.Schedules.Any(s => s.End < s.Start)); | ||
|
||
// act | ||
var actual = new QueryBuilder<Item>() | ||
.AddMap("start", p => p.Schedules.Select(x => x.Start)) | ||
.AddMap("end", p => p.Schedules.Select(x => x.End)) | ||
.AddCondition("end < (start)") | ||
.Build(items.AsQueryable()); | ||
|
||
// assert | ||
Assert.Equal(expected.ToString(), actual.ToString()); | ||
} | ||
|
||
private record Item(string Name, List<TimeSchedule> Schedules); | ||
private record TimeSchedule(int Start, int End); | ||
} |