Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search] Add missing property when cloning SearchOptions #27582

Merged
merged 4 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ private static void Copy(SearchOptions source, SearchOptions destination)
destination.Select = source.Select;
destination.SemanticConfigurationName = source.SemanticConfigurationName;
destination.SemanticFields = source.SemanticFields;
destination.SessionId = source.SessionId;
destination.Size = source.Size;
destination.Skip = source.Skip;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,34 @@ await resources.GetQueryClient().SearchAsync<Hotel>(
ids);
}

[Test]
public void SearchOptionsCanBeCopied()
{
SearchOptions source = new();

source.Facets = new List<string> { "facet1", "facet2" };
source.Filter = "searchFilter";
// source.IncludeTotalCount = null;
source.QueryCaptionHighlightEnabled = false;
// source.QueryType = null;
source.Select = null;
source.SessionId = "SessionId";
source.Size = 100;
source.Skip = null;

SearchOptions clonedSearchOptions = source.Clone();

CollectionAssert.AreEquivalent(source.Facets, clonedSearchOptions.Facets); // A non-null collection with multiple items
Assert.AreEqual(source.Filter, clonedSearchOptions.Filter); // A string value
Assert.IsNull(clonedSearchOptions.IncludeTotalCount); // An unset bool? value
Assert.AreEqual(source.QueryCaptionHighlightEnabled, clonedSearchOptions.QueryCaptionHighlightEnabled); // A bool? value
Assert.IsNull(source.QueryType); // An unset enum? value
Assert.IsNull(clonedSearchOptions.Select); // A `null` collection
Assert.AreEqual(source.SessionId, clonedSearchOptions.SessionId); // A string value
Assert.AreEqual(source.Size, clonedSearchOptions.Size); // An int? value
Assert.IsNull(clonedSearchOptions.Skip); // An int? value set as `null`
}

/* TODO: Enable these Track 1 tests when we have support for index creation
protected void TestCanSearchWithDateTimeInStaticModel()
{
Expand Down