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); }