Esempio n. 1
0
        public void TopHits_Json()
        {
            var top = AggregationsHelper.TopHitsAggregation(
                ParameterHelper.Sort(
                    new KeyValuePair <Expression <Func <IndexedClass, object> >, AggsOrderDirection>(ic => ic.AString,
                                                                                                     AggsOrderDirection.Desc),
                    new KeyValuePair <Expression <Func <IndexedClass, object> >, AggsOrderDirection>(ic => ic.SomeNumber,
                                                                                                     AggsOrderDirection.Asc)
                    ),
                ParameterHelper.Include <IndexedClass>(ic => ic.ObjectId, ic => ic.MockEnum)
                );
            var json = JsonConvert.SerializeObject(top, JsonHelpers.CreateSerializerSettings());

            Assert.AreEqual("{\"top_hits\":{\"_source\":{\"includes\":[\"ObjectId\",\"MockEnum\"]},\"sort\":[{\"AString\":\"Desc\"},{\"SomeNumber\":\"Asc\"}]}}", json);
        }