public void PASS_Serialize_Field_Script() { ValueCountAggregate agg = new ValueCountAggregate("name", "field", new Script("script")); string json = JsonConvert.SerializeObject(agg); Assert.IsNotNull(json); string expectedJson = "{\"name\":{\"value_count\":{\"field\":\"field\",\"script\":\"script\"}}}"; Assert.AreEqual(expectedJson, json); }
public void PASS_Serialize() { ValueCountAggregate agg = new ValueCountAggregate("name", "field", new Script("script") { Language = "lang", Parameters = new List<ScriptParameter>() { new ScriptParameter("name", "value") } }); string json = JsonConvert.SerializeObject(agg); Assert.IsNotNull(json); string expectedJson = "{\"name\":{\"value_count\":{\"field\":\"field\",\"lang\":\"lang\",\"script\":\"script\",\"params\":{\"name\":\"value\"}}}}"; Assert.AreEqual(expectedJson, json); }
public void PASS_Create() { ValueCountAggregate agg = new ValueCountAggregate("name", "field", new Script("script") { Language = "lang", Parameters = new List<ScriptParameter>() { new ScriptParameter("name", "value") } }); Assert.IsNotNull(agg); Assert.AreEqual("name", agg.Name); Assert.AreEqual("field", agg.Field); Assert.AreEqual("script", agg.Script.ScriptText); Assert.AreEqual("name", agg.Script.Parameters.First().Name); Assert.AreEqual("value", agg.Script.Parameters.First().Value); }