示例#1
0
        public void can_copy_null_value_nullable_enum_to_nullable_int_as_null()
        {
            var input = new SingleProp <TestEnum?> {
                Value = null
            };
            var output = input.Copy <SingleProp <TestEnum?>, SingleProp <int?> >();

            Assert.AreEqual(null, output.Value);
        }
示例#2
0
        public void can_copy_class_to_struct()
        {
            var input = new SingleProp <int> {
                Value = 1
            };
            var output = input.Copy <SingleProp <int>, SinglePropStruct <int> >();

            Assert.AreEqual(input.Value, output.Value);
        }
示例#3
0
        public void can_copy_null_nullable_int_to_long()
        {
            var input = new SingleProp <int?> {
                Value = (int?)null
            };
            var output = input.Copy <SingleProp <int?>, SingleProp <long> >();

            Assert.AreEqual(0, output.Value);
        }
示例#4
0
        public void can_copy_name_without_id_to_name_ending_in_id_enum()
        {
            var input = new SingleProp <TestEnum> {
                Value = TestEnum.Something
            };
            var output = input.Copy <SingleProp <TestEnum>, SingleId <int> >();

            Assert.AreEqual(1, output.ValueId);
        }
示例#5
0
        public void can_copy_nullable_long_to_long()
        {
            var input = new SingleProp <long?> {
                Value = 1
            };
            var output = input.Copy <SingleProp <long?>, SingleProp <long> >();

            Assert.AreEqual(input.Value.Value, output.Value);
        }
示例#6
0
        public void can_copy_null_nullable_long_to_default()
        {
            var input = new SingleProp <long?> {
                Value = (long?)null
            };
            var output = input.Copy <SingleProp <long?>, SingleProp <long> >();

            Assert.AreEqual(0, output.Value);
        }
示例#7
0
        public void can_copy_nullable_enum_to_nullable_int()
        {
            var input = new SingleProp <TestEnum?> {
                Value = TestEnum.Something
            };
            var output = input.Copy <SingleProp <TestEnum?>, SingleProp <int?> >();

            Assert.AreEqual(1, output.Value);
        }
示例#8
0
        public void can_copy_nullable_int_to_int()
        {
            var input = new SingleProp <int?> {
                Value = 1
            };
            var output = input.Copy <SingleProp <int?>, SingleProp <int> >();

            Assert.AreEqual(1, output.Value);
        }
示例#9
0
        public void can_copy_nullable_long_to_nullable_enum()
        {
            var input = new SingleProp <long?> {
                Value = 1
            };
            SingleProp <TestEnum?> output = input.Copy <SingleProp <long?>, SingleProp <TestEnum?> >();

            Assert.AreEqual((TestEnum)input.Value, output.Value);
        }
示例#10
0
        public void can_copy_long_to_enum()
        {
            var input = new SingleProp <long> {
                Value = 1
            };
            var output = input.Copy <SingleProp <long>, SingleProp <TestEnum> >();

            Assert.AreEqual((TestEnum)input.Value, output.Value);
        }
示例#11
0
        public void can_copy_enum_to_another_enum()
        {
            var input = new SingleProp <TestEnum> {
                Value = TestEnum.Something
            };
            var output = input.Copy <SingleProp <TestEnum>, SingleProp <TestEnum2> >();

            Assert.AreEqual((int)input.Value, (int)output.Value);
        }
示例#12
0
        public void can_copy_enum_to_long()
        {
            var input = new SingleProp <TestEnum> {
                Value = TestEnum.Something
            };
            var output = input.Copy <SingleProp <TestEnum>, SingleProp <long> >();

            Assert.AreEqual((long)input.Value, output.Value);
        }
示例#13
0
        public void can_clone_datetime_property()
        {
            var input = new SingleProp <DateTime> {
                Value = DateTime.Now
            };
            var copy = input.Copy();

            Assert.AreNotSame(input, copy);
            Assert.AreEqual(input.Value, copy.Value);
        }
示例#14
0
        public void can_CopyTo_existing_object_when_existing_is_null()
        {
            var input = new SingleProp <int> {
                Value = 1
            };
            SingleProp <int> existing = null;
            var output = input.CopyTo(existing);

            Assert.AreEqual(input.Value, output.Value);
        }
示例#15
0
        public void can_clone_decimal_property()
        {
            var input = new SingleProp <decimal> {
                Value = 1.1m
            };
            var copy = input.Copy();

            Assert.AreNotSame(input, copy);
            Assert.AreEqual(input.Value, copy.Value);
        }
示例#16
0
        public void can_clone_float_property()
        {
            var input = new SingleProp <float> {
                Value = 1.1f
            };
            var copy = input.Copy();

            Assert.AreNotSame(input, copy);
            Assert.AreEqual(input.Value, copy.Value);
        }
示例#17
0
        public void can_clone_bool_property()
        {
            var input = new SingleProp <bool> {
                Value = true
            };
            var copy = input.Copy();

            Assert.AreNotSame(input, copy);
            Assert.AreEqual(input.Value, copy.Value);
        }
示例#18
0
        public void can_clone_array_property()
        {
            var input = new SingleProp <decimal[]> {
                Value = new [] { 1m, 2m }
            };
            var copy = input.Copy();

            Assert.AreNotSame(input, copy);
            Assert.AreSame(input.Value, copy.Value);
        }
示例#19
0
        public void can_clone_string_property()
        {
            var input = new SingleProp <string> {
                Value = "hello"
            };
            var copy = input.Copy();

            Assert.AreNotSame(input, copy);
            Assert.AreSame(input.Value, copy.Value);
        }
        public void can_map_null_string()
        {
            var input = new SingleProp <string> {
                Value = null
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.VarChar, 10) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1, recs.Count, "Count");
            Assert.AreEqual(true, recs[0].IsDBNull(0));
        }
        public void can_map_null_decimal()
        {
            var input = new SingleProp <decimal?> {
                Value = null
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.Decimal) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(true, recs[0].IsDBNull(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }
        public void can_map_decimal()
        {
            var input = new SingleProp <decimal> {
                Value = 1.111m
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.Decimal) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1.111m, recs[0].GetValue(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }
        public void can_map_float()
        {
            var input = new SingleProp <float> {
                Value = 1f
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.Real) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1f, recs[0].GetValue(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }
        public void can_map_long()
        {
            var input = new SingleProp <long> {
                Value = 1
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.BigInt) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1L, recs[0].GetValue(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }
        public void can_map_boolean()
        {
            var input = new SingleProp <bool> {
                Value = true
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.Bit) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1, recs.Count, "Count");
            Assert.AreEqual(true, recs[0].GetValue(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }
        public void cannot_map_custom_type_so_null_value_instead()
        {
            var input = new SingleProp <Stuff> {
                Value = new Stuff()
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.Int) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1, recs.Count, "Count");
            Assert.AreEqual(1, recs[0].FieldCount);
            Assert.IsTrue(recs[0].IsDBNull(0));
        }
        public void can_map_enum_to_int()
        {
            var input = new SingleProp <TestEnum> {
                Value = TestEnum.Something
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.Int) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1, recs.Count, "Count");
            Assert.AreEqual(1, recs[0].GetInt32(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }
        public void can_map_nullable_datetime()
        {
            var input = new SingleProp <DateTime?> {
                Value = DateTime.Now
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.DateTime) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1, recs.Count, "Count");
            Assert.AreEqual(input.Value.Value, recs[0].GetValue(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }
        public void can_map_short()
        {
            var input = new SingleProp <short> {
                Value = 1
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.SmallInt) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1, recs.Count, "Count");
            Assert.AreEqual((short)1, recs[0].GetValue(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }
        public void can_map_nullable_byte()
        {
            var input = new SingleProp <byte?> {
                Value = 1
            };
            var meta = new[] { new SqlMetaData("VALUE", SqlDbType.TinyInt) };
            var recs = new[] { input }.ToDataRecords(meta).ToList();

            Assert.AreEqual(1, recs.Count, "Count");
            Assert.AreEqual((byte)1, recs[0].GetValue(0));
            Assert.AreEqual(1, recs[0].FieldCount);
        }