public void Test() { Utilities.Validation.Rules.GreaterThanOrEqual<ClassA, int> TestObject = new GreaterThanOrEqual<ClassA, int>(x => x.ItemA, 3, "Error"); ClassA Temp = new ClassA(); Temp.ItemA = 3; Assert.DoesNotThrow<Exception>(() => TestObject.Validate(Temp)); Temp.ItemA = 2; Assert.Throws<NotValid>(() => TestObject.Validate(Temp)); }
public void Test() { Utilities.Validation.Rules.NotBetween<ClassA, int> TestObject = new NotBetween<ClassA, int>(x => x.ItemA, 1, 5, "Error"); ClassA Temp = new ClassA(); Temp.ItemA = 0; Assert.DoesNotThrow<Exception>(() => TestObject.Validate(Temp)); Temp.ItemA = 1; Assert.Throws<NotValid>(() => TestObject.Validate(Temp)); }
public void Test() { Utilities.Validation.Rules.LessThan<ClassA, int> TestObject = new LessThan<ClassA, int>(x => x.ItemA, 3, "Error"); ClassA Temp = new ClassA(); Temp.ItemA = 2; Assert.DoesNotThrow(() => TestObject.Validate(Temp)); Temp.ItemA = 3; Assert.Throws<NotValid>(() => TestObject.Validate(Temp)); }
public void Test() { Utilities.Validation.Rules.Custom<ClassA, int> TestObject = new Custom<ClassA, int>(x => x.ItemA, x => MyAction(x)); ClassA Temp = new ClassA(); Temp.ItemA = 1; Assert.DoesNotThrow(() => TestObject.Validate(Temp)); Temp = null; Assert.Throws<NotValid>(() => TestObject.Validate(Temp)); }
public void Test() { ClassA Temp = new ClassA(); Temp.ItemA = 1; Temp.ItemB = DateTime.Now; Temp.Validate(); Temp.ItemA = 0; Temp.ItemB = new DateTime(1800, 1, 1); Assert.Throws<ValidationException>(() => Temp.Validate()); }
public void MyAction(ClassA Param) { if (Param == null) throw new NotValid("Error"); }