Esempio n. 1
0
        public void ConvUtils_ToBoolean()
        {
            Assert.IsTrue(ConvUtils.ToBooleanEx("true"), "Result differs");
            Assert.IsTrue(ConvUtils.ToBooleanEx("TRUE"), "Result differs");
            Assert.IsTrue(ConvUtils.ToBooleanEx("1"), "Result differs");
            Assert.IsFalse(ConvUtils.ToBooleanEx("false"), "Result differs");
            Assert.IsFalse(ConvUtils.ToBooleanEx(""), "Result differs");

            bool?nres;

            nres = ConvUtils.NullableToBooleanEx(null);
            Assert.IsNull(nres, "Not null result");
            nres = ConvUtils.NullableToBooleanEx(String.Empty);
            Assert.IsNull(nres, "Not null result");
            nres = ConvUtils.NullableToBooleanEx("");
            Assert.IsNull(nres, "Not null result");
            nres = ConvUtils.NullableToBooleanEx("true");
            Assert.AreEqual(true, nres, "Result differs");
            nres = ConvUtils.NullableToBooleanEx("0");
            Assert.AreEqual(false, nres, "Result differs");
        }