Skip to content

Commit

Permalink
test: add issue test case
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezanet committed Jun 22, 2024
1 parent ffb6366 commit 915c87b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/Gridify.Tests/IssueTests/Issue155Tests.cs
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);
}

0 comments on commit 915c87b

Please sign in to comment.