public void ConvertTo_returns_correct_result_for_DateTime() { DateTime?val = NullSafe.ConvertTo <DateTime>("2012-10-19"); Assert.IsTrue(val.HasValue); Assert.AreEqual(new DateTime(2012, 10, 19), val.Value); }
public void ConvertTo_returns_correct_result_for_ulong() { ulong?val = NullSafe.ConvertTo <ulong>("5"); Assert.IsTrue(val.HasValue); Assert.AreEqual(5, val.Value); }
public void ConvertTo_returns_null_for_impossible_conversion() { int?val = NullSafe.ConvertTo <int>("foo"); Assert.IsFalse(val.HasValue); val = NullSafe.ConvertTo <int>(null); Assert.IsFalse(val.HasValue); }