public void ConstructorAllowsNullSize() { var facet = new TermsStatsFacet(ExpectedName, ExpectedKey, ExpectedValue, null); Assert.Same(ExpectedName, facet.Name); Assert.Null(facet.Size); }
public void ConstructorAllowsNullFilter() { var facet = new TermsStatsFacet(ExpectedName, null, ExpectedKey, ExpectedValue); Assert.Same(ExpectedName, facet.Name); Assert.Null(facet.Filter); }
public void ConstructorWithSizeSetsAllProperties() { var facet = new TermsStatsFacet(ExpectedName, ExpectedKey, ExpectedValue, expectedSize); Assert.Same(ExpectedName, facet.Name); Assert.Same(ExpectedKey, facet.Key); Assert.Same(ExpectedValue, facet.Value); Assert.Equal(expectedSize, facet.Size); Assert.Null(facet.Filter); }
static JToken Build(TermsStatsFacet termStatsFacet) { return new JObject( new JProperty("key_field", termStatsFacet.Key), new JProperty("value_field", termStatsFacet.Value) ); }
public void BodyContainsTermsStatsFacet() { const int expectedSize = 101; var expectedFacet = new TermsStatsFacet("Name", "Key", "Value", expectedSize); var searchRequest = new SearchRequest { Facets = new List<IFacet>(new[] { expectedFacet }) }; var formatter = new SearchRequestFormatter(defaultConnection, mapping, searchRequest); var body = JObject.Parse(formatter.Body); var result = body.TraverseWithAssert("facets", expectedFacet.Name, expectedFacet.Type); Assert.Equal(expectedFacet.Key, result.TraverseWithAssert("key_field").ToString()); Assert.Equal(expectedFacet.Value, result.TraverseWithAssert("value_field").ToString()); Assert.Equal(expectedSize.ToString(CultureInfo.InvariantCulture), result.TraverseWithAssert("size").ToString()); }
public void TypePropertyIsAlwaysTermStats() { var facet = new TermsStatsFacet(ExpectedName, ExpectedKey, ExpectedValue, 1); Assert.Equal("terms_stats", facet.Type); }