Skip to content

Commit

Permalink
Added offset test to search options builder
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerohegartyDfE committed Nov 4, 2024
1 parent 51bebad commit 8188746
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ public void Build_WithSize_SearchOptionsWithCorrectSize()
searchOptions.Size.Should().Be(100);
}

[Fact]
public void Build_WithOfset_SearchOptionsWithCorrectOffset()
{
// arrange
ISearchFilterExpressionsBuilder mockSearchFilterExpressionsBuilder = new FilterExpressionBuilderTestDouble().Create();

ISearchOptionsBuilder searchOptionsBuilder = new SearchOptionsBuilder(mockSearchFilterExpressionsBuilder);

// act
SearchOptions searchOptions = searchOptionsBuilder.WithOffset(offset: 39).Build();

// assert
searchOptions.Should().NotBeNull();
searchOptions.Skip.Should().Be(39);
}

[Fact]
public void Build_WithSearchMode_SearchOptionsWithCorrectSearchMode()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public async Task Search_WithValidSearchContext_ReturnsResults()
await cognitiveSearchServiceAdapter.SearchAsync(
new SearchServiceAdapterRequest(
searchKeyword: "SearchKeyword",
offset: 0,
searchFields: ["FIELD1", "FIELD2", "FIELD2"],
facets: ["FACET1", "FACET2", "FACET3"]));
facets: ["FACET1", "FACET2", "FACET3"],
offset: 99));

// assert
response.Should().NotBeNull();
Expand Down Expand Up @@ -94,9 +94,9 @@ public async Task Search_WithNoFacetsReturned_ReturnsNullFacets()
await cognitiveSearchServiceAdapter.SearchAsync(
new SearchServiceAdapterRequest(
searchKeyword: "SearchKeyword",
offset: 0,
searchFields: ["FIELD1", "FIELD2", "FIELD2"],
facets: ["FACET1", "FACET2", "FACET3"]));
facets: ["FACET1", "FACET2", "FACET3"],
offset: 0));

// assert
response.Should().NotBeNull();
Expand Down Expand Up @@ -129,9 +129,9 @@ public async Task Search_WithNoResultsReturned_ReturnsEmptyResults()
await cognitiveSearchServiceAdapter.SearchAsync(
new SearchServiceAdapterRequest(
searchKeyword: "SearchKeyword",
offset: 0,
searchFields: ["FIELD1", "FIELD2", "FIELD2"],
facets: ["FACET1", "FACET2", "FACET3"]));
facets: ["FACET1", "FACET2", "FACET3"],
offset: 0));

// assert
response.Should().NotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public sealed class SearchServiceAdapterRequest
/// Dictionary of search filter requests where key is the name of the filter and the value is the list of filter values.
/// </param>
/// <param name="offset">
/// The value used to define how many records are skipped in the search response (if any).
/// The value used to define how many records are skipped in the search response
/// (if any), by default we choose not to skip any records.
/// </param>
/// <exception cref="ArgumentNullException">
/// The exception thrown if an invalid search keyword (null or whitespace) is prescribed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public sealed class SearchByKeywordRequest
/// The string keyword used to search the collection specified.
/// </param>
/// <param name="offset">
/// The value used to define how many records are skipped in the search response (if any).
/// The value used to define how many records are skipped in the search
/// response (if any), by default we choose not to skip any records.
/// </param>
public SearchByKeywordRequest(string searchKeyword, int offset = 0)
{
Expand Down

0 comments on commit 8188746

Please sign in to comment.