public void ShouldCallBaseForToString() { IPolleableConfig config = new PolleableConfig(); config.LoadTimeout = new Optional<int>(20); config.PollingTimeout = new Optional<int>(30); config.PollingInterval = new Optional<int>(5); config.AdditionalProperties.Add("field1", "field1_val"); config.AdditionalProperties.Add("field2", true); config.AdditionalProperties.Add("field3", 50); Assert.AreEqual("PolleableConfig(LoadableConfig(LoadTimeout: " + config.LoadTimeout.ToString() + ", AdditionalProperties: Dictionary([field1, field1_val],[field2, True],[field3, 50])), " + "PollingTimeout: " + config.PollingTimeout.ToString() + ", PollingInterval: " + config.PollingInterval.ToString() + ")", config.ToString()); }
public void ShouldSerializePolleableWithUndefinedPollingTimeout() { string json = @"{ '$type': 'Org.Brixen.Config.PolleableConfig, Org.Brixen.Config', 'LoadTimeout': 70, 'PollingInterval': 5 }"; JObject jsonObj = JObject.Parse(json); IPolleableConfig config = new PolleableConfig(); config.LoadTimeout = new Optional<int>(70); config.PollingInterval = new Optional<int>(5); string output = JsonConvert.SerializeObject(config, Formatting.Indented, settings); JObject result = JObject.Parse(output); Assert.AreEqual(jsonObj, result, "The serialized JSON of a polleable config with an undefined polling " + "timeout is not correct"); Assert.IsNull(result.SelectToken("PollingTimeout"), "There should be no polling timeout token in the " + "serialized JSON for a polleable config with an undefined polling timeout"); }