public void TestSearchAggregate__WithTooManyResults__ReturnsHasMoreResults() { var aggregator = new SearchResultAggregator(0, 5); aggregator.Push(new long[] { 1, 2 }); aggregator.Push(new long[] { 3, 4 }); aggregator.Push(new long[] { 5, 6 }); Assert.True(aggregator.TooManyResults); Assert.Equal(0, aggregator.Remaining); }
public void TestSearchAggregate__WithOffset__SkipsTheCorrectOffset() { var aggregator = new SearchResultAggregator(5, 5); aggregator.Push(new long[] { 1, 2 }); aggregator.Push(new long[] { 3, 4 }); aggregator.Push(new long[] { 5, 6, 7 }); Assert.False(aggregator.TooManyResults); Assert.Equal(3, aggregator.Remaining); Assert.Equal(aggregator.Results, new long[] { 6, 7 }); }
public void TestSearchAggregate__WithOffsetAndLimit__CorrectlyDeterminesThereAreTooManyResults() { var aggregator = new SearchResultAggregator(5, 5); aggregator.Push(new long[] { 1, 2 }); aggregator.Push(new long[] { 3, 4, 42 }); aggregator.Push(new long[] { 5, 6, 7 }); aggregator.Push(new long[] { 8, 9, 10 }); Assert.True(aggregator.TooManyResults); Assert.Equal(0, aggregator.Remaining); Assert.Equal(aggregator.Results, new long[] { 5, 6, 7, 8, 9 }); }
public async Task <SearchResult> FindAnswersForQuestion(PangulDbContext db, UserContext user, string questionId, int offset, int limit) { // Normally the offset would be passed to the search aggregate, but in this case we already deal with that in the query. var aggregate = new SearchResultAggregator(0, limit); var ids = await _getAnswerIds.Execute(db, new GetAnswerIds() { UserContext = user, QuestionId = questionId, Limit = limit, Offset = offset }); aggregate.Push(ids); return(aggregate.AsResult()); }