Exemplo n.º 1
0
        public void TestInts(Type targetType)
        {
            var data = new object[] { 1, 2, 3 };

            IEnumerable result = ParamAttributeTypeConversions.ConvertData(data, targetType);

            CollectionAssert.AllItemsAreInstancesOfType(result, targetType);
        }
Exemplo n.º 2
0
        public void TestStringToDateTime()
        {
            var data     = new object[] { "1970/01/01", "02/01/1980", "1999/12/31" };
            var expected = new DateTime[] { new DateTime(1970, 1, 1), new DateTime(1980, 2, 1), new DateTime(1999, 12, 31) };

            IEnumerable result = ParamAttributeTypeConversions.ConvertData(data, typeof(DateTime));

            Assert.That(result, Is.EquivalentTo(expected).And.All.TypeOf <DateTime>());
        }
Exemplo n.º 3
0
        public void TestStringToDecimal()
        {
            var data     = new object[] { "0.1", "1.0", "-1.0" };
            var expected = new decimal[] { 0.1M, 1.0M, -1.0M };

            IEnumerable result = ParamAttributeTypeConversions.ConvertData(data, typeof(decimal));

            Assert.That(result, Is.EquivalentTo(expected).And.All.TypeOf <decimal>());
        }
        public void TestEmtpyDataToEnum()
        {
            var data     = new object[] { };
            var expected = new TestEnum[] { TestEnum.Value1, TestEnum.Value2, TestEnum.value3 };

            IEnumerable result = ParamAttributeTypeConversions.ConvertData(data, typeof(TestEnum));

            Assert.That(result, Is.EquivalentTo(expected));
        }
        public void TestEmtpyDataToBool()
        {
            var data     = new object[] { };
            var expected = new bool[] { true, false };

            IEnumerable result = ParamAttributeTypeConversions.ConvertData(data, typeof(bool));

            Assert.That(result, Is.EquivalentTo(expected));
        }
Exemplo n.º 6
0
 public static void NullTypeArgumentShouldThrowArgumentNullException()
 {
     Assert.That(() => ParamAttributeTypeConversions.ConvertData(new object[0], null), Throws.ArgumentNullException);
 }
Exemplo n.º 7
0
 public static void NullDataArgumentShouldThrowArgumentNullException()
 {
     Assert.That(() => ParamAttributeTypeConversions.ConvertData(null, typeof(object)), Throws.ArgumentNullException);
 }