public void TestConvertWithFormat() { var converter = new LabelConverter(); converter.Format = "N2"; const double Value = 3.3333333; var expected = string.Format(CultureInfo.CurrentCulture, "{0:N2}", Value); Assert.AreEqual(expected, converter.Convert(Value, typeof(string), null, CultureInfo.InvariantCulture)); converter.Format = "%"; Assert.AreEqual(string.Format(@"3{0}33%", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator), converter.Convert(3.33, typeof(string), null, CultureInfo.InvariantCulture)); converter.Format = "P3"; Assert.AreEqual(string.Format("{0:P3}", Value / 100.0), converter.Convert(Value, typeof(string), null, CultureInfo.InvariantCulture)); }
public void TestConvertWithoutFormat() { var converter = new LabelConverter(); converter.Format = null; Assert.AreEqual(3.3333333, converter.Convert(3.3333333, typeof(string), null, CultureInfo.InvariantCulture)); }