public void ConversionUtility_ToBoolean_1() { Assert.AreEqual(true, ConversionUtility.ToBoolean("true")); Assert.AreEqual(true, ConversionUtility.ToBoolean("yes")); Assert.AreEqual(false, ConversionUtility.ToBoolean("false")); Assert.AreEqual(false, ConversionUtility.ToBoolean("no")); }
/// <summary> /// Get boolean value from application configuration. /// </summary> /// <param name="key"></param> /// <param name="defaultValue"></param> /// <returns></returns> public static bool GetBoolean ( string key, bool defaultValue) { string s = CM.AppSettings [key]; if (!string.IsNullOrEmpty(s)) { defaultValue = ConversionUtility.ToBoolean(s); } return(defaultValue); }
/// <summary> /// Get boolean value from application configuration. /// </summary> public static bool GetBoolean ( [NotNull] string key, bool defaultValue = false ) { bool result = defaultValue; string setting = CM.AppSettings[key]; if (!string.IsNullOrEmpty(setting)) { result = ConversionUtility.ToBoolean(setting); } return(result); }
/// <summary> /// Get boolean value from application configuration. /// </summary> public static bool GetBoolean ( [NotNull] string key, bool defaultValue ) { #if DROID || ANDROID || UAP return(defaultValue); #else bool result = defaultValue; string s = CM.AppSettings[key]; if (!string.IsNullOrEmpty(s)) { result = ConversionUtility.ToBoolean(s); } return(result); #endif }
public void ConversionUtility_ToBoolean_6() { ConversionUtility.ToBoolean("bullshit"); }
public void ConversionUtility_ToBoolean_5() { ConversionUtility.ToBoolean(new SourceType2()); }
public void ConversionUtility_ToBoolean_4() { // TypeConverter Assert.AreEqual(false, ConversionUtility.ToBoolean(new SourceType())); }
public void ConversionUtility_ToBoolean_3() { // value is IConverttible Assert.AreEqual(true, ConversionUtility.ToBoolean(1)); Assert.AreEqual(false, ConversionUtility.ToBoolean(0)); }
public void ConversionUtility_ToBoolean_2() { // value is bool Assert.AreEqual(true, ConversionUtility.ToBoolean(true)); Assert.AreEqual(false, ConversionUtility.ToBoolean(false)); }