Exemplo n.º 1
0
        public void ConvertTo_TypeError2()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();

            Assert.AreEqual("59", cv.ConvertTo(null, null, 59, typeof(int)), "A1");
            Assert.AreEqual("59", cv.ConvertTo(null, null, 59, null), "A2");
        }
Exemplo n.º 2
0
        public void ConvertFrom_TypeError()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();
            object o;

            o = cv.ConvertFrom(null, null, "hi");
            Assert.IsNull(o, "A1");
        }
Exemplo n.º 3
0
        public void ConvertFrom_FormatError()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();
            object o;

            o = cv.ConvertFrom(null, null, "100.5");
            Assert.IsNull(o, "A1");
        }
Exemplo n.º 4
0
        public void ConvertFrom_TypeError()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();
            object o = null;

            Assert.Throws <FormatException>(() => o = cv.ConvertFrom(null, null, "hi"));
            Assert.Null(o);
        }
Exemplo n.º 5
0
        public void CanConvertTo()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();

            Assert.IsTrue(cv.CanConvertTo(null, typeof(string)), "A1");
            Assert.IsFalse(cv.CanConvertTo(null, typeof(TimeSpan)), "A2");
            Assert.IsFalse(cv.CanConvertTo(null, typeof(int)), "A3");
            Assert.IsFalse(cv.CanConvertTo(null, typeof(object)), "A4");
        }
Exemplo n.º 6
0
        public void ConvertTo()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();

            Assert.AreEqual("59", cv.ConvertTo(null, null, 59, typeof(string)), "A1");

            Assert.AreEqual("144", cv.ConvertTo(null, null, 144, typeof(string)), "A2");

            /* infinity tests */
            Assert.AreEqual("Infinite", cv.ConvertTo(null, null, Int32.MaxValue, typeof(string)), "A3");
            Assert.AreEqual("2147483646", cv.ConvertTo(null, null, Int32.MaxValue - 1, typeof(string)), "A4");
        }
Exemplo n.º 7
0
        public void ConvertFrom()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();
            object o;

            o = cv.ConvertFrom(null, null, "59");
            Assert.AreEqual(typeof(int), o.GetType(), "A1");
            Assert.AreEqual(59, o, "A2");

            /* and now test infinity */
            o = cv.ConvertFrom(null, null, "Infinite");
            Assert.AreEqual(Int32.MaxValue, o, "A3");
        }
Exemplo n.º 8
0
        public void ConvertTo_TypeError1()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();

            Assert.AreEqual("59", cv.ConvertTo(null, null, "hi", typeof(string)), "A1");
        }
Exemplo n.º 9
0
        public void ConvertTo_NullError()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();

            Assert.AreEqual("", cv.ConvertTo(null, null, null, typeof(string)), "A1");
        }
Exemplo n.º 10
0
        public void ConvertTo_TypeError1()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();

            AssertExtensions.Throws <ArgumentException>(null, () => cv.ConvertTo(null, null, "hi", typeof(string)));
        }
Exemplo n.º 11
0
        public void ConvertTo_NullError()
        {
            InfiniteIntConverter cv = new InfiniteIntConverter();

            Assert.Throws <NullReferenceException>(() => cv.ConvertTo(null, null, null, typeof(string)));
        }