public void ReturnsTypedArray() { ConversionProcessor cp = new ConversionProcessor(); object result = cp.Process(new object[] { 0, 1 }, new object[] { typeof(int) }); Assert.IsTrue(result is int[]); }
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 ); }
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); }
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); }
public void RequiresTypeArgument() { ConversionProcessor cp = new ConversionProcessor(); try { cp.Process(new object[] {0, 1}, null); Assert.Fail("should throw"); } catch (ArgumentNullException) { } }
public void RequiresTypeArgument() { ConversionProcessor cp = new ConversionProcessor(); try { cp.Process(new object[] { 0, 1 }, null); Assert.Fail("should throw"); } catch (ArgumentNullException) { } }
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 ); }
public void ReturnsTypedArray() { ConversionProcessor cp = new ConversionProcessor(); object result = cp.Process( new object[] { 0, 1 }, new object[] { typeof(int) }); Assert.IsTrue( result is int[] ); }