예제 #1
0
        public void CanConvertDecimalToDouble()
        {
            var source = new Dictionary <string, object> {
                { "Value", 1.0m }
            };
            var    target = ConcreteTypeCreator.Get(typeof(DecimalToDouble));
            object actual;

            Assert.IsTrue(target.TryCreate(source, out actual));
            Assert.IsInstanceOf <DecimalToDouble>(actual);
            Assert.AreEqual(1.0d, ((DecimalToDouble)actual).Value);
        }
예제 #2
0
        public void CanConvertStringToEnum()
        {
            var expected = Int32ToEnum.Numbers.One;
            var source   = new Dictionary <string, object> {
                { "Value", expected.ToString() }
            };
            var    target = ConcreteTypeCreator.Get(typeof(Int32ToEnum));
            object actual;

            Assert.IsTrue(target.TryCreate(source, out actual));
            Assert.IsInstanceOf <Int32ToEnum>(actual);
            Assert.AreEqual(expected, ((Int32ToEnum)actual).Value);
        }
예제 #3
0
        public void CanConvertDateTimeToNullableDateTime()
        {
            var expected = new DateTime(2011, 9, 8);
            var source   = new Dictionary <string, object> {
                { "Value", expected }
            };
            var    target = ConcreteTypeCreator.Get(typeof(DateTimeToNullableDateTime));
            object actual;

            Assert.IsTrue(target.TryCreate(source, out actual));
            Assert.IsInstanceOf <DateTimeToNullableDateTime>(actual);
            Assert.IsTrue(((DateTimeToNullableDateTime)actual).Value.HasValue);
            Assert.AreEqual(expected, ((DateTimeToNullableDateTime)actual).Value.Value);
        }