public async Task OneConditionFilters() { // One condition should filter the results await using var request = Context.CreateRequest <TestResource>() .WithCondition(nameof(TestResource.Id), Operators.GREATER_THAN, 10); request.Selector = () => TestResource.Generate(20); await using var result = await request.GetResult(); await using var serialized = await result.Serialize(); Assert.Equal(10, serialized.EntityCount); }
public async Task MaxValueOffsetReturnsNoEntities() { await using var request = Context.CreateRequest <TestResource>(); request.Selector = () => TestResource.Generate(20); request.MetaConditions.Offset = int.MaxValue; await using var result = await request.GetResult(); await using var serialized = await result.Serialize(); Assert.Equal(0, serialized.EntityCount); }
public async Task ZeroOffsetAppliesNoOffset() { await using var request = Context.CreateRequest <TestResource>(); request.Selector = () => TestResource.Generate(20); request.MetaConditions.Offset = 0; await using var result = await request.GetResult(); await using var serialized = await result.Serialize(); Assert.Equal(20, serialized.EntityCount); }
public async Task NegativeLimitReturnsAllEntities() { await using var request = Context.CreateRequest <TestResource>(); request.Selector = () => TestResource.Generate(20); request.MetaConditions.Limit = -1; await using var result = await request.GetResult(); await using var serialized = await result.Serialize(); Assert.Equal(20, serialized.EntityCount); }
public async Task TwoConditionsFilter() { // Two conditions should filter the results await using var request = Context.CreateRequest <TestResource>() .WithCondition(nameof(TestResource.Id), Operators.GREATER_THAN, 10) .WithCondition(nameof(TestResource.Name) + ".1", Operators.EQUALS, 'a'); // second letter in name is 'a' request.Selector = () => TestResource.Generate(20); await using var result = await request.GetResult(); await using var serialized = await result.Serialize(); Assert.Equal(5, serialized.EntityCount); }
public async Task PositiveOffsetOffsetsEntities() { await using var request = Context.CreateRequest <TestResource>(); request.Selector = () => TestResource.Generate(20); request.MetaConditions.Offset = 5; await using var result = await request.GetResult(); await using var serialized = await result.Serialize(); Assert.Equal(15, serialized.EntityCount); var first = await result.ToEntities <TestResource>().FirstAsync(); Assert.Equal(6, first.Id); }
public async Task NegativeOffsetAppliesNegativeSkip() { await using var request = Context.CreateRequest <TestResource>(); request.Selector = () => TestResource.Generate(20); request.MetaConditions.Offset = -5; await using var result = await request.GetResult(); await using var serialized = await result.Serialize(); Assert.Equal(5, serialized.EntityCount); var first = await result.ToEntities <TestResource>().FirstAsync(); Assert.Equal(16, first.Id); var last = await result.ToEntities <TestResource>().LastAsync(); Assert.Equal(20, last.Id); }