Esempio n. 1
0
        public void TestMethodAssertEqualLessThan()
        {
            var obj1 = new DateTime(42);
            var obj2 = new DateTime(4242);

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

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

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

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

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