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); Assert.IsInstanceOf(typeof(CRUDFieldValidationException), error); Assert.AreEqual("History2", ((CRUDFieldValidationException)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); Assert.IsInstanceOf(typeof(CRUDFieldValidationException), error); Assert.AreEqual("Description", ((CRUDFieldValidationException)error).FieldName); Assert.IsTrue(error.Message.Contains("Chaplin")); }