public void FacetFieldParameter002() { // Arrange var expected = JObject.Parse(@" { ""facet"": { ""Id"": { ""terms"": { ""field"": ""_id_"", ""mincount"": 1, ""sort"": { ""count"": ""desc"" } } } } }"); string actual; var jObject = new JObject(); var expressionCache = new ExpressionCache <TestDocument>(); var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache); var parameter = new FacetFieldParameter <TestDocument>(expressionBuilder); parameter.Configure(q => q.Id, FacetSortType.CountDesc); // Act parameter.Execute(jObject); actual = jObject.ToString(); // Assert Assert.Equal(expected.ToString(), actual); }
public void FacetFieldParameter005() { // Arrange var expected = JObject.Parse(@" { ""facet"": { ""Id"": { ""terms"": { ""field"": ""_id_"", ""mincount"": 1, ""domain"":{ ""excludeTags"": [ ""tag1"", ""tag2"" ] } } } } }"); string actual; var jObject = new JObject(); var expressionCache = new ExpressionCache <TestDocument>(); var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache); var parameter = new FacetFieldParameter <TestDocument>(expressionBuilder); parameter.Configure(q => q.Id, excludes: new[] { "tag1", "tag2" }); // Act parameter.Execute(jObject); actual = jObject.ToString(); // Assert Assert.Equal(expected.ToString(), actual); }
public void FacetFieldParameter004() { // Arrange var container = new List <string>(); var expressionCache = new ExpressionCache <TestDocument>(); var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache); var parameter = new FacetFieldParameter <TestDocument>(expressionBuilder); parameter.Configure(q => q.Id, FacetSortType.IndexDesc); // Act / Assert Assert.Throws <UnsupportedSortTypeException>(() => parameter.Execute(container)); }
public void FacetFieldParameter001() { // Arrange var container = new List <string>(); var expressionCache = new ExpressionCache <TestDocument>(); var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache); var parameter = new FacetFieldParameter <TestDocument>(expressionBuilder); parameter.Configure(q => q.Id); // Act parameter.Execute(container); // Assert Assert.Equal(3, container.Count); Assert.Equal("facet=true", container[0]); Assert.Equal("facet.field={!key=Id}_id_", container[1]); Assert.Equal("f._id_.facet.mincount=1", container[2]); }