public void Construction_ApplyDefaultValues_ResultIsEqual() { String expected = "TrueValue: \"true\", FalseValue: \"false\", NullValue: \"\", TrueValues: [\"true\", \"1\", \"y\", \"yes\"], FalseValues: [\"false\", \"0\", \"n\", \"no\"], NullValues: [\"<null>\"]"; CsvMappings mapping = new CsvMappings(); Assert.AreEqual(expected, mapping.ToString()); }
public void ConvertToString_QuotingIsTrueForStrings_ResultAsExpected(Object value, Boolean expected) { CultureInfo culture = CultureInfo.CurrentUICulture; CsvMappings mapping = new CsvMappings(); ProcessHelper.ConvertToString(value, culture, mapping, out Boolean actual); Assert.That(actual, Is.EqualTo(expected)); }
public void Construction_ApplyOtherValues_ResultIsEqual() { String expected = "TrueValue: \"wow\", FalseValue: \"awesome\", NullValue: \"don't care\", TrueValues: [\"yes\", \"yepp\"], FalseValues: [\"no\", \"nope\"], NullValues: [\"hello\", \"empty\"]"; CsvMappings mapping = new CsvMappings() { TrueValue = "wow", FalseValue = "awesome", NullValue = "don't care", TrueValues = new List <String> { "yes", "yepp" }, FalseValues = new List <String> { "no", "nope" }, NullValues = new List <String> { "hello", "empty" }, }; Assert.AreEqual(expected, mapping.ToString()); }
/// <summary> /// This method tries to convert an object into its string representation. /// </summary> /// <remarks> /// The <paramref name="quoting"/> out parameter is only true if given /// value is of type string. Otherwise, this parameter is false. /// </remarks> /// <param name="value"> /// The object to get its string representation for. /// </param> /// <param name="culture"> /// The culture to be used for data conversion. /// </param> /// <param name="mapping"> /// The mapping to be used for value transformation. /// </param> /// <param name="quoting"> /// The out parameter that describes if an object value should be surrounded /// by double-quotes. /// </param> /// <returns> /// The string representation of given object. /// </returns> /// <seealso cref="ConvertToString(Object, CultureInfo, CsvMappings)"/> public static String ConvertToString(Object value, CultureInfo culture, CsvMappings mapping, out Boolean quoting) { quoting = (value is String); return(TypeConverter.IntoString(value, culture, mapping)); }
/// <summary> /// This method tries to convert an object into its string representation. /// </summary> /// <remarks> /// This method converts provided object into its string representation but /// without taking the surrounding double-quotes into account. /// </remarks> /// <param name="value"> /// The object to get its string representation for. /// </param> /// <param name="culture"> /// The culture to be used for data conversion. /// </param> /// <param name="mapping"> /// The mapping to be used for value transformation. /// </param> /// <returns> /// The string representation of given object. /// </returns> /// <seealso cref="ConvertToString(Object, CultureInfo, CsvMappings, out Boolean)"/> public static String ConvertToString(Object value, CultureInfo culture, CsvMappings mapping) { return(ProcessHelper.ConvertToString(value, culture, mapping, out Boolean quoting)); }