public void TypedDoc_3() { var doc = new Doc1 { Field1 = "a" }; //In list Aver.IsNull(doc.Validate()); doc.Field1 = "d"; Aver.IsNull(doc.Validate()); }
public void TypedDoc_5() { var doc = new Doc1 { Field3 = "a" }; //In list Aver.IsNull(doc.Validate()); doc.Field3 = "b"; Aver.IsNull(doc.Validate()); doc.Field3 = "n"; Aver.IsNull(doc.Validate()); }
public void TypedDoc_6() { var doc = new Doc1 { Field3 = "I can not be here" }; //NOT In list var ve = doc.Validate() as FieldValidationException; Aver.IsNotNull(ve); Conout.WriteLine(ve.ToMessageWithType()); Aver.AreEqual("Field3", ve.FieldName); doc.Field3 = "n";//'Nancy' obtained from dynamic imperative call Aver.IsNull(doc.Validate()); }
public void TypedDoc_4() { var doc = new Doc1 { Field1 = "Z" }; //NOT In list var ve = doc.Validate() as FieldValidationException; Aver.IsNotNull(ve); Conout.WriteLine(ve.ToMessageWithType()); Aver.AreEqual("Field1", ve.FieldName); doc.Field1 = "c"; Aver.IsNull(doc.Validate()); }
public void TypedDoc_2() { var doc = new Doc1 { }; //nothing is required Aver.IsNull(doc.Validate()); }
public void Test01_Batch() { var doc1 = new Doc1 { S1 = "shr", S2 = "none", I1 = 120 }; var got = doc1.Validate(new ValidState(null, ValidErrorMode.Batch)); got.See(); Aver.IsTrue(got.IsAssigned); Aver.IsTrue(got.HasErrors); Aver.IsFalse(got.NoErrors); Aver.AreEqual(3, got.ErrorCount); Aver.IsTrue(got.ShouldContinue); Aver.IsFalse(got.ShouldStop); Aver.IsNotNull(got.Error); var batch = got.Error as ValidationBatchException; Aver.IsNotNull(batch); Aver.IsNotNull(batch.Batch); Aver.AreEqual(3, batch.Batch.Count); Aver.IsTrue(batch.Batch.OfType <FieldValidationException>().Any(e => e.FieldName == "I1")); Aver.IsTrue(batch.Batch.OfType <FieldValidationException>().Any(e => e.FieldName == "S1")); Aver.IsTrue(batch.Batch.OfType <FieldValidationException>().Any(e => e.FieldName == "S2")); Aver.IsTrue(batch.Batch.Any(e => e.Message.Contains("length of 5"))); Aver.IsTrue(batch.Batch.Any(e => e.Message.Contains("list of allowed"))); Aver.IsTrue(batch.Batch.Any(e => e.Message.Contains("max bound"))); }
public void Test02_Batch() { var doc1 = new Doc1 { S1 = "shr", S2 = "01", I1 = 15 }; var got = doc1.Validate(new ValidState(null, ValidErrorMode.Batch)); got.See(); Aver.IsTrue(got.IsAssigned); Aver.IsTrue(got.HasErrors); Aver.IsFalse(got.NoErrors); Aver.AreEqual(1, got.ErrorCount); Aver.IsTrue(got.ShouldContinue); Aver.IsFalse(got.ShouldStop); Aver.IsNotNull(got.Error); var fve = got.Error as FieldValidationException; Aver.IsNotNull(fve); Aver.IsTrue(fve.Message.Contains("length of 5")); }
public void TypedDoc_7() { var doc = new Doc1 { Field2 = "a" }; //In list Aver.IsNull(doc.Validate()); doc.Field2 = "ap"; Aver.IsNull(doc.Validate()); doc.Field2 = "azz"; Aver.IsNotNull(doc.Validate()); doc.Field2 = "b"; Aver.IsNull(doc.Validate()); doc.Field2 = "ba"; Aver.IsNull(doc.Validate()); doc.Field2 = "bazz"; Aver.IsNotNull(doc.Validate()); doc.Field2 = "c"; Aver.IsNull(doc.Validate()); doc.Field2 = "ch"; Aver.IsNull(doc.Validate()); doc.Field2 = "d"; Aver.IsNull(doc.Validate()); doc.Field2 = "dy"; Aver.IsNull(doc.Validate()); doc.Field2 = "di"; Aver.IsNull(doc.Validate()); }