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 GuidDefaultsToEmptyWhenNull() { var convertible = new DefaultConvertible(null); Guid value = convertible.ToGuid(); Assert.AreEqual(Guid.Empty, value); }
public void CanConvertGuid() { Guid actual = Guid.NewGuid(); var convertible = new DefaultConvertible(actual.ToString()); Guid value = convertible.ToGuid(); Assert.AreEqual(actual, value); object oValue = convertible.ToType(typeof(Guid), CultureInfo.InvariantCulture); Assert.AreEqual(actual, oValue); }
public void GuidDefaultsToEmpty() { var convertible = new DefaultConvertible("GetSome"); Guid value = convertible.ToGuid(); Assert.AreEqual(Guid.Empty, value); convertible = new DefaultConvertible("{0x100000000, 0xED42, 0x11CE, {0xBA, 0xCD, 0x00, 0xAA, 0x00, 0x57, 0xB2, 0x23}}"); value = convertible.ToGuid(); Assert.AreEqual(Guid.Empty, value); }
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 GuidDefaultsToEmptyWhenNull() { var convertible = new DefaultConvertible(null); Guid value = convertible.ToGuid(); Assert.AreEqual(Guid.Empty, value); }
public void GuidDefaultsToEmpty() { var convertible = new DefaultConvertible("GetSome"); Guid value = convertible.ToGuid(); Assert.AreEqual(Guid.Empty, value); convertible = new DefaultConvertible("{0x100000000, 0xED42, 0x11CE, {0xBA, 0xCD, 0x00, 0xAA, 0x00, 0x57, 0xB2, 0x23}}"); value = convertible.ToGuid(); Assert.AreEqual(Guid.Empty, value); }
public void CanConvertGuid() { Guid actual = Guid.NewGuid(); var convertible = new DefaultConvertible(actual.ToString()); Guid value = convertible.ToGuid(); Assert.AreEqual(actual, value); object oValue = convertible.ToType(typeof(Guid), CultureInfo.InvariantCulture); Assert.AreEqual(actual, oValue); }