-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/field-alias
- Loading branch information
Showing
5 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...r.ContentGraph.UnitTests/ResponseDeserializationTests/DynamicAutoCompleteResponseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Xunit; | ||
using Newtonsoft.Json; | ||
using EPiServer.ContentGraph.Api.Result; | ||
|
||
namespace EpiServer.ContentGraph.UnitTests.DeserializationTets | ||
{ | ||
public class DynamicAutoCompleteResponseTests | ||
{ | ||
const string response = "{\"data\":{\"Object\":{\"autocomplete\":{\"Categories\":{\"ProviderName\":[\"Sample Category\"]},\"WebsiteUrl\":[\"http://example.com/\",\"https://test.com/\"]},\"total\":2}},\"extensions\":{\"correlationId\":\"866380417b4f1fb0\",\"cost\":72,\"costSummary\":[\"CompanyBlock(72)=basicFilter(1)*2+autocomplete(2)*35\"]}}"; | ||
[Fact] | ||
public void nested_aotucompletes_should_convert_successfully() | ||
{ | ||
var results = JsonSerializer.CreateDefault().Deserialize<ContentGraphResult<object>>(new JsonTextReader(new StringReader(response))); | ||
var autoCompletesDict = results.Content.AutoComplete; | ||
Assert.True(autoCompletesDict.Count.Equals(2)); | ||
|
||
Assert.NotNull(autoCompletesDict["Categories.ProviderName"]); | ||
Assert.True(autoCompletesDict["Categories.ProviderName"].Count().Equals(1)); | ||
|
||
Assert.NotNull(autoCompletesDict["WebsiteUrl"]); | ||
Assert.True(autoCompletesDict["WebsiteUrl"].Count().Equals(2)); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...iServer.ContentGraph.UnitTests/ResponseDeserializationTests/DynamicFacetsResponseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Xunit; | ||
using Newtonsoft.Json; | ||
using EPiServer.ContentGraph.Api.Result; | ||
|
||
namespace EpiServer.ContentGraph.UnitTests.DeserializationTets | ||
{ | ||
public class DynamicFacetsResponseTests | ||
{ | ||
const string response = "{\"data\":{\"Object\":{\"items\":[{\"Name\":\"Coreware\"}],\"facets\":{\"Categories\":{\"Id\":[{\"name\":\"100\",\"count\":3}],\"Language\":{\"Name\":[{\"name\":\"en\",\"count\":3}]}},\"Name\":[{\"name\":\"Farfetch\",\"count\":3},{\"name\":\"Geta\",\"count\":3}]},\"total\":1154}},\"extensions\":{\"correlationId\":\"8662284c0889108a\",\"cost\":62,\"costSummary\":[\"CompanyBlock(62)=basicFilter(1)*2+facets(2)*30\"]}}"; | ||
[Fact] | ||
public void nested_facets_response_should_convert_successfully() | ||
{ | ||
var results = JsonSerializer.CreateDefault().Deserialize<ContentGraphResult<object>>(new JsonTextReader(new StringReader(response))); | ||
var facetsDict = results.Content.Facets; | ||
Assert.True(facetsDict.Count.Equals(3)); | ||
|
||
Assert.NotNull(facetsDict["Categories.Id"]); | ||
Assert.True(facetsDict["Categories.Id"].Count().Equals(1)); | ||
|
||
Assert.NotNull(facetsDict["Categories.Language.Name"]); | ||
Assert.True(facetsDict["Categories.Language.Name"].Count().Equals(1)); | ||
|
||
Assert.NotNull(facetsDict["Name"]); | ||
Assert.True(facetsDict["Name"].Count().Equals(2)); | ||
} | ||
} | ||
} |