public void TryConvert_DecimalConversion_ResultIsEqual(String actual, Type type, Boolean isTrue, Object expected) { Object result = null; if (isTrue) { Assert.IsTrue(OptionTypeConverter.TryConvert(actual, type, out result)); } else { Assert.IsFalse(OptionTypeConverter.TryConvert(actual, type, out result)); } Assert.AreEqual(result, expected == null ? expected : Decimal.Parse(expected.ToString())); }
// This doesn't actually work! [TestCase("-3.40282347E+38", typeof(Single), true, Single.MinValue)] // This doesn't actually work! [TestCase("-3.40282347E+38", typeof(Single?), true, Single.MinValue)] // This doesn't actually work! [TestCase("3.40282347E+38", typeof(Single), true, Single.MaxValue)] // This doesn't actually work! [TestCase("3.40282347E+38", typeof(Single?), true, Single.MaxValue)] public void TryConvert_SingleConversion_ResultIsEqual(String actual, Type type, Boolean isTrue, Object expected) { Object result = null; if (isTrue) { Assert.IsTrue(OptionTypeConverter.TryConvert(actual, type, out result)); } else { Assert.IsFalse(OptionTypeConverter.TryConvert(actual, type, out result)); } Assert.AreEqual(result, expected); }
public void TryConvert_DateTimeConversion_ResultIsEqual(String actual, Type type, Boolean isTrue, Object expected) { Object result = null; if (expected != null && expected.ToString().StartsWith("current-date")) { expected = (Object)expected.ToString().Replace("current-date", DateTime.Today.ToString("dd.MM.yyyy")); } if (isTrue) { Assert.IsTrue(OptionTypeConverter.TryConvert(actual, type, out result)); } else { Assert.IsFalse(OptionTypeConverter.TryConvert(actual, type, out result)); } Assert.AreEqual(result, expected == null ? expected : DateTime.Parse(expected.ToString())); }