예제 #1
0
        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()));
        }
예제 #2
0
        // 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);
        }
예제 #3
0
        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()));
        }