public void Validation3() { Console.WriteLine("Validation3"); var request = new XRequest { GeneralItemView = new GeneralItemView { Id = 1 }, XChild1 = new XChild1 { GeneralItemView = new GeneralItemView { Id = 1 }, XChild2 = new XChild2 { GeneralItemView = new GeneralItemView { Id = 1 } } } }; var validationErrorInfos = new DataAnnotationsValidatorManager().GetErrors(request); validationErrorInfos.ToList().ForEach(x => Console.WriteLine(x.FormatErrorMessage)); Assert.AreEqual(0, validationErrorInfos.Count); }
public void Validation6() { Console.WriteLine("Validation6"); var request = new XRequest { GeneralItemView = new GeneralItemView { Id = 1 }, XChild1 = new XChild1 { GeneralItemView = new GeneralItemView { Id = 1 }, XChild2 = new XChild2 { GeneralItemView = new GeneralItemView { Id = 1 }, XChild3 = new XChild3 { GeneralItemView = new GeneralItemView { Id = 1 }, XChild4 = new XChild4 { GeneralItemView = new GeneralItemView { Id = 1 }, XChild5 = new XChild5 { XChild6 = null } } } } } }; Console.WriteLine("Validation6-Test1"); IDataAnnotationsValidatorManager validationManager = new DataAnnotationsValidatorManager(); var validationErrorInfos = validationManager.GetErrors(request); validationErrorInfos.ToList().ForEach(x => Console.WriteLine(x.FormatErrorMessage)); Assert.AreEqual(0, validationErrorInfos.Count); Console.WriteLine("Validation6-Test2"); validationManager.DefaultMaxDepthLevel = 6; validationErrorInfos = validationManager.GetErrors(request); validationErrorInfos.ToList().ForEach(x => Console.WriteLine(x.FormatErrorMessage)); Assert.AreEqual(1, validationErrorInfos.Count); Console.WriteLine("Validation6-Complete"); }