public void PaddingConverter_ConvertFrom_String_ReturnsExpected(string value, object expected) { var converter = new PaddingConverter(); Assert.Equal(expected, converter.ConvertFrom(value)); Assert.Equal(expected, converter.ConvertFrom(null, null, value)); }
public void ConvertFrom() { string listSeparator = CultureInfo.CurrentCulture.TextInfo.ListSeparator; PaddingConverter pc = new PaddingConverter(); Assert.AreEqual(new Padding(1, 2, 3, 4), pc.ConvertFrom( string.Format("1{0} 2{0} 3{0} 4", listSeparator)), "A1"); Assert.AreEqual(new Padding(1, 2, 3, 4), pc.ConvertFrom( string.Format("1{0}2{0}3{0}4", listSeparator)), "A2"); Assert.AreEqual(new Padding(1, 2, 3, 4), pc.ConvertFrom( string.Format("1{0} 2{0} 3{0} 4", listSeparator)), "A3"); Assert.AreEqual(new Padding(1), pc.ConvertFrom(string.Format( "1{0} 1{0} 1{0} 1", listSeparator)), "A4"); Assert.AreEqual(new Padding(), pc.ConvertFrom(string.Format( "0{0} 0{0} 0{0} 0", listSeparator)), "A5"); }
private Padding RoundTripPadding(Padding p) { PaddingConverter pc = new PaddingConverter(); string s = (string)pc.ConvertTo(p, typeof(string)); return((Padding)pc.ConvertFrom(s)); }
public void PaddingConverter_ConvertFrom_InvalidString_ThrowsArgumentException(string value) { var converter = new PaddingConverter(); Assert.Throws <ArgumentException>(null, () => converter.ConvertFrom(value)); }
public void PaddingConverter_ConvertFrom_InvalidValue_ThrowsNotSupportedException(object value) { var converter = new PaddingConverter(); Assert.Throws <NotSupportedException>(() => converter.ConvertFrom(value)); }