Skip to content

Commit

Permalink
[Search] Enhance 'FacetsArentAutomaticallyParsed` test (#27237)
Browse files Browse the repository at this point in the history
Add some more common "date-looking" strings and verify they are not automatically parsed as `DateTimeOffset`
  • Loading branch information
Mohit-Chakraborty authored Feb 28, 2022
1 parent 50f7c35 commit 02e201a
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ await client.UploadDocumentsAsync(
new FacetKeyValuePair("1", "9-6"),
new FacetKeyValuePair("2", "9.6"),
new FacetKeyValuePair("3", "9'6\""),
new FacetKeyValuePair("4", "9/6"),
new FacetKeyValuePair("5", "9\\6"),
});
await resources.WaitForIndexingAsync();

Expand All @@ -694,13 +696,15 @@ await resources.GetQueryClient().SearchAsync<FacetKeyValuePair>(

Assert.IsNotNull(response.Value.Facets);
AssertFacetsEqual(
GetFacetsForField(response.Value.Facets, "Value", 3),
GetFacetsForField(response.Value.Facets, "Value", 5),
MakeValueFacet(1, "9'6\""),
MakeValueFacet(1, "9-6"),
MakeValueFacet(1, "9.6"));
MakeValueFacet(1, "9.6"),
MakeValueFacet(1, "9/6"),
MakeValueFacet(1, "9\\6"));

// Check strongly typed value facets
ICollection<FacetResult> facets = GetFacetsForField(response.Value.Facets, "Value", 3);
ICollection<FacetResult> facets = GetFacetsForField(response.Value.Facets, "Value", 5);
ValueFacetResult<string> first = facets.ElementAt(0).AsValueFacetResult<string>();
Assert.AreEqual("9'6\"", first.Value);
Assert.AreEqual(1, first.Count);
Expand All @@ -710,6 +714,12 @@ await resources.GetQueryClient().SearchAsync<FacetKeyValuePair>(
ValueFacetResult<string> third = facets.ElementAt(2).AsValueFacetResult<string>();
Assert.AreEqual("9.6", third.Value);
Assert.AreEqual(1, third.Count);
ValueFacetResult<string> fourth = facets.ElementAt(3).AsValueFacetResult<string>();
Assert.AreEqual("9/6", fourth.Value);
Assert.AreEqual(1, fourth.Count);
ValueFacetResult<string> fifth = facets.ElementAt(4).AsValueFacetResult<string>();
Assert.AreEqual("9\\6", fifth.Value);
Assert.AreEqual(1, fifth.Count);
}

[Test]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 02e201a

Please sign in to comment.