예제 #1
0
        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));
        }
예제 #2
0
        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");
        }
예제 #3
0
        private Padding RoundTripPadding(Padding p)
        {
            PaddingConverter pc = new PaddingConverter();

            string s = (string)pc.ConvertTo(p, typeof(string));

            return((Padding)pc.ConvertFrom(s));
        }
예제 #4
0
        public void PaddingConverter_ConvertFrom_InvalidString_ThrowsArgumentException(string value)
        {
            var converter = new PaddingConverter();

            Assert.Throws <ArgumentException>(null, () => converter.ConvertFrom(value));
        }
예제 #5
0
        public void PaddingConverter_ConvertFrom_InvalidValue_ThrowsNotSupportedException(object value)
        {
            var converter = new PaddingConverter();

            Assert.Throws <NotSupportedException>(() => converter.ConvertFrom(value));
        }