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 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."); }
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."); }
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."); }
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 ConvertFromNullReference() { StringArrayConverter vrt = new StringArrayConverter(); vrt.ConvertFrom(null); }
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."); }
public void ConvertFromNullReference() { StringArrayConverter vrt = new StringArrayConverter(); Assert.Throws <NotSupportedException>(() => vrt.ConvertFrom(null)); }