public void ConvertFromPreservesExtraneousWhitespace()
 {
     object[] expected = new object[] {"1 ", " Foo ", " 3"};
     StringArrayConverter vrt = new StringArrayConverter();
     object actual = vrt.ConvertFrom("1 , Foo , 3");
     Assert.IsNotNull(actual);
     Assert.AreEqual(typeof (string[]), actual.GetType());
     Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[]) actual),
         "Individual array elements not correctly converted (check the whitespace?).");
 }
예제 #2
0
        public void ConvertFromPreservesExtraneousWhitespace()
        {
            object[]             expected = new object[] { "1 ", " Foo ", " 3" };
            StringArrayConverter vrt      = new StringArrayConverter();
            object actual = vrt.ConvertFrom("1 , Foo , 3");

            Assert.IsNotNull(actual);
            Assert.AreEqual(typeof(string[]), actual.GetType());
            Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[])actual),
                          "Individual array elements not correctly converted (check the whitespace?).");
        }
 public void ConvertFrom()
 {
     object[] expected = new object[] {"1", "Foo", "3"};
     StringArrayConverter vrt = new StringArrayConverter();
     object actual = vrt.ConvertFrom("1,Foo,3");
     Assert.IsNotNull(actual);
     Assert.AreEqual(typeof (string[]), actual.GetType());
     Assert.AreEqual(3, ((string[]) actual).Length, "Wrong number of elements in the resulting array.");
     Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[]) actual),
         "Individual array elements not correctly converted.");
 }
예제 #4
0
        public void ConvertFrom()
        {
            object[]             expected = new object[] { "1", "Foo", "3" };
            StringArrayConverter vrt      = new StringArrayConverter();
            object actual = vrt.ConvertFrom("1,Foo,3");

            Assert.IsNotNull(actual);
            Assert.AreEqual(typeof(string[]), actual.GetType());
            Assert.AreEqual(3, ((string[])actual).Length, "Wrong number of elements in the resulting array.");
            Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[])actual),
                          "Individual array elements not correctly converted.");
        }
예제 #5
0
        public void NullingTheListSeparatorMakesItRevertToTheDefault()
        {
            object[]             expected = new object[] { "1", "Foo", "3" };
            StringArrayConverter vrt      = new StringArrayConverter();

            vrt.ListSeparator = null;
            object actual = vrt.ConvertFrom("1,Foo,3");

            Assert.IsNotNull(actual);
            Assert.AreEqual(typeof(string[]), actual.GetType());
            Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[])actual),
                          "Individual array elements not correctly converted.");
        }
예제 #6
0
        public void CustomListSeparator()
        {
            object[]             expected        = new object[] { "1", "Foo", "3" };
            StringArrayConverter vrt             = new StringArrayConverter();
            const string         customSeparator = "#";

            vrt.ListSeparator = customSeparator;
            object actual = vrt.ConvertFrom(string.Format("1{0}Foo{0}3", customSeparator));

            Assert.IsNotNull(actual);
            Assert.AreEqual(typeof(string[]), actual.GetType());
            Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[])actual),
                          "Individual array elements not correctly converted.");
        }
예제 #7
0
        public void EnsureCultureListSeparatorIsIgnored()
        {
            CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;

            try
            {
                CultureInfo frenchCulture = new CultureInfo("fr-FR");
                Thread.CurrentThread.CurrentCulture = frenchCulture;
                object[]             expected = new object[] { "1", "Foo", "3" };
                StringArrayConverter vrt      = new StringArrayConverter();
                // France uses the ';' (semi-colon) to separate list items...
                object actual = vrt.ConvertFrom("1,Foo,3");
                Assert.IsNotNull(actual);
                Assert.AreEqual(typeof(string[]), actual.GetType());
                Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[])actual),
                              "Individual array elements not correctly converted.");
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = originalCulture;
            }
        }
예제 #8
0
        public void ConvertFromNullReference()
        {
            StringArrayConverter vrt = new StringArrayConverter();

            vrt.ConvertFrom(null);
        }
예제 #9
0
        public void ConvertFromNonSupportedOptionBails()
        {
            StringArrayConverter vrt = new StringArrayConverter();

            Assert.Throws <NotSupportedException>(() => vrt.ConvertFrom(12));
        }
 public void ConvertFromNonSupportedOptionBails()
 {
     StringArrayConverter vrt = new StringArrayConverter();
     vrt.ConvertFrom(12);
 }
 public void EnsureCultureListSeparatorIsIgnored()
 {
     CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
     try
     {
         CultureInfo frenchCulture = new CultureInfo("fr-FR");
         Thread.CurrentThread.CurrentCulture = frenchCulture;
         object[] expected = new object[] {"1", "Foo", "3"};
         StringArrayConverter vrt = new StringArrayConverter();
         // France uses the ';' (semi-colon) to separate list items...
         object actual = vrt.ConvertFrom("1,Foo,3");
         Assert.IsNotNull(actual);
         Assert.AreEqual(typeof (string[]), actual.GetType());
         Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[]) actual),
                       "Individual array elements not correctly converted.");
     }
     finally
     {
         Thread.CurrentThread.CurrentCulture = originalCulture;
     }
 }
 public void ConvertFromNonSupportedOptionBails()
 {
     StringArrayConverter vrt = new StringArrayConverter();
     Assert.Throws<NotSupportedException>(() => vrt.ConvertFrom(12));
 }
 public void ConvertFromNullReference()
 {
     StringArrayConverter vrt = new StringArrayConverter();
     Assert.Throws<NotSupportedException>(() => vrt.ConvertFrom(null));
 }
	    public void NullingTheListSeparatorMakesItRevertToTheDefault()
	    {
            object[] expected = new object[] {"1", "Foo", "3"};
	        StringArrayConverter vrt = new StringArrayConverter();
            vrt.ListSeparator = null;
            object actual = vrt.ConvertFrom("1,Foo,3");
            Assert.IsNotNull(actual);
            Assert.AreEqual(typeof (string[]), actual.GetType());
            Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[]) actual),
                "Individual array elements not correctly converted.");
	    }
 public void CustomListSeparator()
 {
     object[] expected = new object[] {"1", "Foo", "3"};
     StringArrayConverter vrt = new StringArrayConverter();
     const string customSeparator = "#";
     vrt.ListSeparator = customSeparator;
     object actual = vrt.ConvertFrom(string.Format("1{0}Foo{0}3", customSeparator));
     Assert.IsNotNull(actual);
     Assert.AreEqual(typeof (string[]), actual.GetType());
     Assert.IsTrue(ArrayUtils.AreEqual(expected, (string[]) actual),
         "Individual array elements not correctly converted.");
 }
예제 #16
0
        public void ConvertFromNonSupportedOptionBails()
        {
            StringArrayConverter vrt = new StringArrayConverter();

            vrt.ConvertFrom(12);
        }
예제 #17
0
        public void ConvertFromNullReference()
        {
            StringArrayConverter vrt = new StringArrayConverter();

            Assert.Throws <NotSupportedException>(() => vrt.ConvertFrom(null));
        }
 public void ConvertFromNullReference()
 {
     StringArrayConverter vrt = new StringArrayConverter();
     vrt.ConvertFrom(null);
 }