You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Try the following test (added to tests\MasterMemory.Tests\DatabaseTest.cs)
Currently the db.SampleTable.FindRangeByAge( min: 2, max: 2) returns a range with Count 1 and pointing at the first element in the sorted list - which has age 9.
The problem is due to First / Last being used on empty element in FindManyRangeCore.
I have a suggested fix; which also improves the efficiency of FindManyRangeCore (in TableBase.cs) which I will attempt to upload. I am not very familiar with git however.
If the above behavior is by design - please let me know.
Steps to create:
Sample[] CreateData()
{
// Id = Unique, PK
// FirstName + LastName = Unique
var data = new[]
{
new Sample { Id = 5, Age = 19, FirstName = "aaa", LastName = "foo" },
new Sample { Id = 6, Age = 29, FirstName = "bbb", LastName = "foo" },
new Sample { Id = 7, Age = 39, FirstName = "ccc", LastName = "foo" },
new Sample { Id = 8, Age = 49, FirstName = "ddd", LastName = "foo" },
new Sample { Id = 1, Age = 59, FirstName = "eee", LastName = "foo" },
new Sample { Id = 2, Age = 89, FirstName = "aaa", LastName = "bar" },
new Sample { Id = 3, Age = 79, FirstName = "be", LastName = "de" },
new Sample { Id = 4, Age = 89, FirstName = "aaa", LastName = "tako" },
new Sample { Id = 9, Age = 99, FirstName = "aaa", LastName = "ika" },
new Sample { Id = 10, Age = 9, FirstName = "eee", LastName = "baz" },
};
return data;
}
[Fact]
public void Ranges()
{
var builder = new DatabaseBuilder();
builder.Append(CreateData());
var bin = builder.Build();
var db = new MemoryDatabase(bin);
db.SampleTable.FindRangeByAge(2,2).Select(x=>x.Id).ToArray().Should().BeEquivalentTo( new int[] {} );
db.SampleTable.FindRangeByAge(30,50).Select(x=>x.Id).ToArray().Should().BeEquivalentTo( new int[] { 7, 8 } );
db.SampleTable.FindRangeByAge(100,100).Select(x=>x.Id).ToArray().Should().BeEquivalentTo( new int[] {} );
}
The text was updated successfully, but these errors were encountered:
Try the following test (added to tests\MasterMemory.Tests\DatabaseTest.cs)
Currently the db.SampleTable.FindRangeByAge( min: 2, max: 2) returns a range with Count 1 and pointing at the first element in the sorted list - which has age 9.
The problem is due to First / Last being used on empty element in FindManyRangeCore.
I have a suggested fix; which also improves the efficiency of FindManyRangeCore (in TableBase.cs) which I will attempt to upload. I am not very familiar with git however.
If the above behavior is by design - please let me know.
Steps to create:
The text was updated successfully, but these errors were encountered: