From 9bb27047a6c7d3723182fea58b17cdd187b37519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Nunes?= Date: Sun, 15 Oct 2023 13:23:23 +0100 Subject: [PATCH] Added boolean join and orderby test --- test/YesSql.Tests/CoreTests.cs | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/test/YesSql.Tests/CoreTests.cs b/test/YesSql.Tests/CoreTests.cs index dc9b7590..9cba09e5 100644 --- a/test/YesSql.Tests/CoreTests.cs +++ b/test/YesSql.Tests/CoreTests.cs @@ -45,7 +45,7 @@ public async Task InitializeAsync() if (_configuration == null) { _configuration = CreateConfiguration(); - + CleanDatabase(_configuration, false); _store = await StoreFactory.CreateAndInitializeAsync(_configuration); @@ -2834,6 +2834,49 @@ public async Task CanCountThenListOrdered() } } + [Fact] + public async Task CanJoinAndOrderByBoolean() + { + _store.RegisterIndexes(); + _store.RegisterIndexes(); + + using (var session = _store.CreateSession()) + { + for (var i = 0; i < 100; i++) + { + var person = new Person + { + Firstname = "Bill" + i, + Lastname = "Gates" + i, + Age = i + }; + + session.Save(person); + } + + await session.SaveChangesAsync(); + } + + using (var session = _store.CreateSession()) + { + var query = session.Query().For() + .All( + x => x.With(x => x.SomeName.Contains("Bill")), + x => x.With(x => x.Age >= 0).OrderByDescending(x => x.Adult) + ); + + var results = await query.ListAsync(); + + Assert.Equal(100, await query.CountAsync()); + Assert.Equal(100, (results).Count()); + + for (int i = 0; i < 82; i++) + { + Assert.True(results.ElementAt(i).Age >= 18); + } + } + } + [Fact] public async Task ShouldPageResults() {