示例#1
0
        public void NeverThrows()
        {
            var convertible = new DefaultConvertible(null);

            convertible.ToChar(CultureInfo.InvariantCulture);
            convertible.ToBoolean(CultureInfo.InvariantCulture);
            convertible.ToByte(CultureInfo.InvariantCulture);
            convertible.ToDateTime(CultureInfo.InvariantCulture);
            convertible.ToDecimal(CultureInfo.InvariantCulture);
            convertible.ToDouble(CultureInfo.InvariantCulture);
            convertible.ToEnum(null);
            convertible.ToGuid();
            convertible.ToInt16(CultureInfo.InvariantCulture);
            convertible.ToInt32(CultureInfo.InvariantCulture);
            convertible.ToInt64(CultureInfo.InvariantCulture);
            convertible.ToSByte(CultureInfo.InvariantCulture);
            convertible.ToSingle(CultureInfo.InvariantCulture);
            convertible.ToString(CultureInfo.InvariantCulture);
            convertible.ToUInt16(CultureInfo.InvariantCulture);
            convertible.ToUInt32(CultureInfo.InvariantCulture);
            convertible.ToUInt64(CultureInfo.InvariantCulture);
            convertible.WithTypeConverter(typeof(string));

            convertible = new DefaultConvertible("FileStyleUriParser");
            convertible.WithTypeConverter(typeof(FileStyleUriParser));
        }
示例#2
0
        public void EnumDefaultsToDefaultWhenNull()
        {
            var convertible = new DefaultConvertible(null);
            var value       = (WeAre)convertible.ToEnum(typeof(WeAre));

            Assert.AreEqual(WeAre.Lovin, value);
        }
示例#3
0
        public void CanConvertEnum()
        {
            var convertible = new DefaultConvertible("Minute");
            var value       = (WeAre)convertible.ToEnum(typeof(WeAre));

            Assert.AreEqual(WeAre.Minute, value);

            object oValue = convertible.ToType(typeof(WeAre), CultureInfo.InvariantCulture);

            Assert.AreEqual(WeAre.Minute, oValue);
        }
        public void NeverThrows()
        {
            var convertible = new DefaultConvertible(null);

            convertible.ToChar(CultureInfo.InvariantCulture);
            convertible.ToBoolean(CultureInfo.InvariantCulture);
            convertible.ToByte(CultureInfo.InvariantCulture);
            convertible.ToDateTime(CultureInfo.InvariantCulture);
            convertible.ToDecimal(CultureInfo.InvariantCulture);
            convertible.ToDouble(CultureInfo.InvariantCulture);
            convertible.ToEnum(null);
            convertible.ToGuid();
            convertible.ToInt16(CultureInfo.InvariantCulture);
            convertible.ToInt32(CultureInfo.InvariantCulture);
            convertible.ToInt64(CultureInfo.InvariantCulture);
            convertible.ToSByte(CultureInfo.InvariantCulture);
            convertible.ToSingle(CultureInfo.InvariantCulture);
            convertible.ToString(CultureInfo.InvariantCulture);
            convertible.ToUInt16(CultureInfo.InvariantCulture);
            convertible.ToUInt32(CultureInfo.InvariantCulture);
            convertible.ToUInt64(CultureInfo.InvariantCulture);
            convertible.WithTypeConverter(typeof(string));

            convertible = new DefaultConvertible("FileStyleUriParser");
            convertible.WithTypeConverter(typeof(FileStyleUriParser));
        }
        public void EnumDefaultsToDefaultWhenNull()
        {
            var convertible = new DefaultConvertible(null);
            var value = (WeAre)convertible.ToEnum(typeof(WeAre));

            Assert.AreEqual(WeAre.Lovin, value);
        }
        public void CanConvertEnum()
        {
            var convertible = new DefaultConvertible("Minute");
            var value = (WeAre)convertible.ToEnum(typeof(WeAre));

            Assert.AreEqual(WeAre.Minute, value);

            object oValue = convertible.ToType(typeof(WeAre), CultureInfo.InvariantCulture);
            Assert.AreEqual(WeAre.Minute, oValue);
        }