Exemplo n.º 1
0
        public void ReturnsListAsIsIfNullOrEmpty()
        {
            ConversionProcessor cp = new ConversionProcessor();
            object result;

            result = cp.Process(null, new object[] { typeof(int) });
            Assert.IsNull(result);
            ICollection input = new object[] {};

            result = cp.Process(input, new object[] { typeof(int) });
            Assert.AreEqual(input, result);
        }
Exemplo n.º 2
0
        public void ReturnsTypedArray()
        {
            ConversionProcessor cp = new ConversionProcessor();
            object result          = cp.Process(new object[] { 0, 1 }, new object[] { typeof(int) });

            Assert.IsTrue(result is int[]);
        }
Exemplo n.º 3
0
        public void UsesTypeConverterRegistryForConversion()
        {
            ConversionProcessor cp     = new ConversionProcessor();
            ICollection         result = (ICollection)cp.Process(new object[] { "0", 1, 1.1m, "1.1", 1.1f }, new object[] { typeof(decimal) });
            decimal             sum    = 0;

            foreach (decimal element in result)
            {
                sum += element;
            }
            Assert.AreEqual(4.3f, sum);
        }
Exemplo n.º 4
0
        public void RequiresTypeArgument()
        {
            ConversionProcessor cp = new ConversionProcessor();

            try
            {
                cp.Process(new object[] { 0, 1 }, null);
                Assert.Fail("should throw");
            }
            catch (ArgumentNullException)
            {
            }
        }