public void Coerce_Throws_Exception_With_Invalid_Values()
        {
            const string input = "1,4,78,abcdefg";

            var coercer = new CsvCoercerAttribute(typeof(int));

            int[] result;
            coercer.Coerce(input, null, null, out result);
        }
Beispiel #2
0
        public void Coerce_Throws_Exception_With_Invalid_Values()
        {
            const string input = "1,4,78,abcdefg";

            var coercer = new CsvCoercerAttribute(typeof(int));

            int[] result;
            coercer.Coerce(input, null, null, out result);
        }
Beispiel #3
0
        public void Coerce_Throws_Exception_For_Unconvertible_Type()
        {
            const string input = null;

            var coercer = new CsvCoercerAttribute(typeof(DescriptionAttribute));

            var coerced = coercer.Coerce(input, null, null, out DescriptionAttribute[] result);

            Assert.IsTrue(coerced);
            Assert.IsNull(result);
        }
Beispiel #4
0
        public void Coerce_Returns_Null_Array_With_Null_String()
        {
            const string input = null;

            var coercer = new CsvCoercerAttribute(typeof(int));

            int[] result;
            var   coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsTrue(coerced);
            Assert.IsNull(result);
        }
Beispiel #5
0
        public void Coerce_Returns_Null_With_Invalid_Type()
        {
            const string input = "1,4,78,222";

            var coercer = new CsvCoercerAttribute(typeof(int));

            long[] result;
            var    coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsFalse(coerced);
            Assert.IsNull(result);
        }
        public void Coerce_Throws_Exception_For_Unconvertible_Type()
        {
            const string input = null;

            var coercer = new CsvCoercerAttribute(typeof(DescriptionAttribute));

            DescriptionAttribute[] result;
            var coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsTrue(coerced);
            Assert.IsNull(result);
        }
        public void Coerce_Returns_Null_With_Invalid_Type()
        {
            const string input = "1,4,78,222";

            var coercer = new CsvCoercerAttribute(typeof(int));

            long[] result;
            var coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsFalse(coerced);
            Assert.IsNull(result);
        }
        public void Coerce_Returns_Null_Array_With_Null_String()
        {
            const string input = null;

            var coercer = new CsvCoercerAttribute(typeof(int));

            int[] result;
            var coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsTrue(coerced);
            Assert.IsNull(result);
        }
Beispiel #9
0
        public void Coerce_Returns_Empty_Array_With_Empty_String()
        {
            const string input = "";

            var coercer = new CsvCoercerAttribute(typeof(int));

            int[] result;
            var   coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(int[]));
            Assert.IsTrue(coerced);
        }
Beispiel #10
0
        public void Coerce_Works_With_Custom_Separator()
        {
            const string input    = "1 | 4 | 78 | 222";
            var          expected = new int[] { 1, 4, 78, 222 };

            var coercer = new CsvCoercerAttribute(typeof(int), " | ");

            int[] result;
            var   coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsTrue(coerced);
            CollectionAssert.AreEqual(expected, result);
        }
Beispiel #11
0
        public void Coerce_Works_With_Array_Of_Int()
        {
            const string input    = "1,4,78,222";
            var          expected = new [] { 1, 4, 78, 222 };

            var coercer = new CsvCoercerAttribute(typeof(int));

            int[] result;
            var   coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsTrue(coerced);
            CollectionAssert.AreEqual(expected, result);
        }
        public void Coerce_Returns_Empty_Array_With_Empty_String()
        {
            const string input = "";

            var coercer = new CsvCoercerAttribute(typeof(int));

            int[] result;
            var coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(int[]));
            Assert.IsTrue(coerced);
        }
        public void Coerce_Works_With_Array_Of_Int()
        {
            const string input = "1,4,78,222";
            var expected = new [] { 1, 4, 78, 222 };

            var coercer = new CsvCoercerAttribute(typeof(int));

            int[] result;
            var coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsTrue(coerced);
            CollectionAssert.AreEqual(expected, result);
        }
        public void Coerce_Works_With_Custom_Separator()
        {
            const string input = "1 | 4 | 78 | 222";
            var expected = new int[] { 1, 4, 78, 222 };

            var coercer = new CsvCoercerAttribute(typeof(int), " | ");

            int[] result;
            var coerced = coercer.Coerce(input, null, null, out result);

            Assert.IsTrue(coerced);
            CollectionAssert.AreEqual(expected, result);
        }