Ejemplo n.º 1
0
        public void Convert_Test_When_Array_Has_Elements_And_Converter_Is_Not_Null_And_Elements_Are_Type_Compatible_And_Value_Convertible()
        {
            string[] array = new string[] { "1", "2", "3" };
            ICustomConverter <string, int> converter = new StringToIntCustomConverter();

            var result = ArrayHelper.ArrayHelper.Convert(array, converter);

            CollectionAssert.AreEqual(new[] { 1, 2, 3 }, result);
        }
Ejemplo n.º 2
0
        public void Convert_Test_When_Array_Has_Elements_And_Converter_Is_Not_Null_And_Elements_Are_Type_Compatible_But_Not_All_Values_Are_Convertible()
        {
            string[] array = new string[] { "1", "2", "bla bla" };
            string[] nonConvertibleStrings;

            ICustomConverter <string, int> converter = new StringToIntCustomConverter();

            var result = ArrayHelper.ArrayHelper.Convert(array, converter, out nonConvertibleStrings);

            CollectionAssert.AreEqual(new[] { 1, 2 }, result);

            CollectionAssert.AreEqual(new[] { "bla bla" }, nonConvertibleStrings);
        }