Skip to content

Commit

Permalink
Added boolean join and orderby test
Browse files Browse the repository at this point in the history
  • Loading branch information
mariojsnunes committed Oct 15, 2023
1 parent df9c173 commit 9bb2704
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion test/YesSql.Tests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task InitializeAsync()
if (_configuration == null)
{
_configuration = CreateConfiguration();

CleanDatabase(_configuration, false);

_store = await StoreFactory.CreateAndInitializeAsync(_configuration);
Expand Down Expand Up @@ -2834,6 +2834,49 @@ public async Task CanCountThenListOrdered()
}
}

[Fact]
public async Task CanJoinAndOrderByBoolean()
{
_store.RegisterIndexes<PersonIndexProvider>();
_store.RegisterIndexes<PersonAgeIndexProvider>();

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<Person>()
.All(
x => x.With<PersonByName>(x => x.SomeName.Contains("Bill")),
x => x.With<PersonByAge>(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()
{
Expand Down

0 comments on commit 9bb2704

Please sign in to comment.