コード例 #1
0
        public void TestMethodAssertLessThan()
        {
            var obj1 = new DateTime(42);
            var obj2 = new DateTime(4242);

            Assert.IsFalse(StfAssert.LessThan("2 < 1", 2, 1));
            Assert.IsFalse(StfAssert.LessThan("2.0 < 1", 2.0, 1));
            Assert.IsTrue(StfAssert.LessThan("1 < \"2\"", 1, "2"));
            Assert.IsFalse(StfAssert.LessThan("1 < \"1.0\"", 1, "1.0"));

            Assert.IsFalse(StfAssert.LessThan("\"\" < \"\"", string.Empty, string.Empty));
            Assert.IsTrue(StfAssert.LessThan("\"\" < \" \"", string.Empty, " "));
            Assert.IsFalse(StfAssert.LessThan("\" \" < \" \"", " ", string.Empty));
            Assert.IsTrue(StfAssert.LessThan("\"a\" < \"A\"", "a", "A"));
            Assert.IsFalse(StfAssert.LessThan("\"A\" < \"a\"", "A", "a"));
            Assert.IsFalse(StfAssert.LessThan("\"string\" < \"string\"", "string", "string"));

            Assert.IsFalse(StfAssert.LessThan("obj1 < obj1", obj1, obj1));
            Assert.IsTrue(StfAssert.LessThan("obj1 < obj2", obj1, obj2));
            Assert.IsFalse(StfAssert.LessThan("obj2 < obj1", obj2, obj1));

            // fail scenarios
            Assert.IsFalse(StfAssert.LessThan("obj1 = 1", obj1, 1));

            // a bit funky - the object obj1 is converted to string, and then the strings are compared.
            Assert.IsFalse(StfAssert.LessThan("obj1 = \"string\"", obj1, "string"));
        }