Skip to content

Commit

Permalink
Additional test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
pschaeflein committed Jul 31, 2023
1 parent aa7d025 commit 2094efa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Models/SearchQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public SearchQuery()
this.Request = new RequestProperties();
}

public SearchQuery(string queryText, List<string> selectProperties = null, List<Sort> sortList = null, long? startRow = null, int? rowLimit = null, int? rowsPerPage = null, bool? trimDuplicates = false)
public SearchQuery(string queryText, List<string> selectProperties = null, List<Sort> sortList = null, long? startRow = null, int? rowLimit = null, int? rowsPerPage = null, bool? trimDuplicates = null)
: this()
{
this.Request.Querytext = queryText;
Expand Down
4 changes: 0 additions & 4 deletions src/Serializer/SPSearchQueryConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ public override void Write(Utf8JsonWriter writer, SearchQuery value, JsonSeriali
{
requestObjectToSerialize.TrimDuplicates = value.Request.TrimDuplicates.Value;
}
else
{
requestObjectToSerialize.TrimDuplicates = false;
}

var objectToSerialize = new
{
Expand Down
10 changes: 10 additions & 0 deletions test/SearchQueryModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ public static IEnumerable<object[]> GetSearchQueries()
new SearchQuery("sharepoint", sortList: new List<SearchQuery.Sort> { { new SearchQuery.Sort{ Property="[docid]", Direction=SearchQuery.SortDirection.Ascending} } }),
"{\"request\":{\"Querytext\":\"sharepoint\",\"SortList\":{\"results\":[{\"Property\":\"[docid]\",\"Direction\":\"0\"}]}}}"
};
yield return new object[]
{
new SearchQuery("sharepoint", new List<string> { "Title", "Path" }, trimDuplicates: false),
"{\"request\":{\"Querytext\":\"sharepoint\",\"SelectProperties\":{\"results\":[\"Title\",\"Path\"]},\"TrimDuplicates\":false}}"
};
yield return new object[]
{
new SearchQuery("sharepoint", new List<string> { "Title", "Path" }, trimDuplicates: true),
"{\"request\":{\"Querytext\":\"sharepoint\",\"SelectProperties\":{\"results\":[\"Title\",\"Path\"]},\"TrimDuplicates\":true}}"
};
}

[Theory]
Expand Down

0 comments on commit 2094efa

Please sign in to comment.