public void Test_LessThan_Exclusive() { LessThanSpecification s = new LessThanSpecification(); s.RefValueExpression = new ConstantExpression(1); Assert.IsTrue(s.Test(0).Success); Assert.IsFalse(s.Test(1).Success); Assert.IsFalse(s.Test(2).Success); // null is less than any other value Assert.IsTrue(s.Test(null).Success); }
public void Test_LessThan_Strict() { LessThanSpecification s = new LessThanSpecification(); s.RefValueExpression = new ConstantExpression("1"); s.Strict = true; // this should fail because in strict mode we don't do type coercion, // and IComparable throws an ArgumentException in this situation s.Test(0); }
public void Test_LessThan_CoerceTypes() { LessThanSpecification s = new LessThanSpecification(); s.RefValueExpression = new ConstantExpression("1"); Assert.IsTrue(s.Test(0).Success); Assert.IsFalse(s.Test(2).Success); Assert.IsFalse(s.Test(1).Success); Assert.IsTrue(s.Test(0.5).Success); Assert.IsFalse(s.Test(2.1).Success); // these will do string comparison, not numeric comparison Assert.IsTrue(s.Test("0.5").Success); Assert.IsFalse(s.Test("2.1").Success); // null is less than any other value Assert.IsTrue(s.Test(null).Success); }
// This test is currently failing because coercion code hasn't been merged to trunk yet public void Test_LessThan_CoerceTypes() { LessThanSpecification s = new LessThanSpecification(); s.RefValueExpression = new ConstantExpression("1"); Assert.IsTrue(s.Test(0).Success); //Assert.IsTrue(s.Test(1).Success); Assert.IsFalse(s.Test(2).Success); //Assert.IsFalse(s.Test(null).Success); Assert.IsFalse(s.Test(1).Success); }