public void Validate_PersonWithNesting_Error_ComplexFieldRequired() { var person = new PersonWithNesting { ID = "POP1", FirstName = "Oleg", LastName = "Popov", DOB = new DateTime(1953, 12, 10), YearsInSpace = 45, Amount = 100, History1 = new List <HistoryItem>(), // History2 = new HistoryItem[2] }; var error = person.Validate(); Console.WriteLine(error); Aver.IsTrue(error is FieldValidationException); Aver.AreEqual("History2", ((FieldValidationException)error).FieldName); }
public void Validate_PersonWithNesting_Error_ComplexFieldSubFieldRequired() { var person = new PersonWithNesting { ID = "POP1", FirstName = "Oleg", LastName = "Popov", DOB = new DateTime(1953, 12, 10), YearsInSpace = 45, Amount = 100, LatestHistory = new HistoryItem { ID = null, StartDate = DateTime.Now, Description = "Chaplin is here" }, History1 = new List <HistoryItem>(), History2 = new HistoryItem[2] }; var error = person.Validate(); Console.WriteLine(error); Aver.IsTrue(error is FieldValidationException); Aver.AreEqual("ID", ((FieldValidationException)error).FieldName); }
public void Validate_PersonWithNesting_Error_ComplexFieldCustomValidation() { var person = new PersonWithNesting { ID = "POP1", FirstName = "Oleg", LastName = "Popov", DOB = new DateTime(1953, 12, 10), YearsInSpace = 45, Amount = 100, LatestHistory = new HistoryItem { ID = "111", StartDate = DateTime.Now, Description = "Someone is an idiot!" }, History1 = new List <HistoryItem>(), History2 = new HistoryItem[2] }; var error = person.Validate(); Console.WriteLine(error); Aver.IsTrue(error is FieldValidationException); Aver.AreEqual("Description", ((FieldValidationException)error).FieldName); Aver.IsTrue(error.Message.Contains("Chaplin")); }