public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { Dictionary<string, object> fieldDict = serializer.Deserialize<Dictionary<string, object>>(reader); DocumentRouting routing = new DocumentRouting(); MappingBase.Deserialize(routing, fieldDict); routing.IsRequired = fieldDict.GetBool(_IS_REQUIRED, DocumentRouting._IS_REQUIRED_DEFAULT); routing.Path = fieldDict.GetStringOrDefault(_PATH); return routing; }
public void PASS_Serialize() { DocumentRouting routing = new DocumentRouting() { Index = IndexSettingEnum.Analyzed, Store = true, IsRequired = true, Path = "obj.prop" }; string json = JsonConvert.SerializeObject(routing); Assert.IsNotNull(json); string expectedJson = "{\"index\":\"analyzed\",\"store\":true,\"required\":true,\"path\":\"obj.prop\"}"; Assert.AreEqual(expectedJson, json); }
public void PASS_Create() { DocumentRouting routing = new DocumentRouting() { Index = IndexSettingEnum.Analyzed, Store = true, IsRequired = true, Path = "obj.prop" }; Assert.IsNotNull(routing); Assert.AreEqual(IndexSettingEnum.Analyzed, routing.Index); Assert.AreEqual(true, routing.Store); Assert.AreEqual(true, routing.IsRequired); Assert.AreEqual("obj.prop", routing.Path); }