public void Update_Person_With_No_Name_Throws_Exception() { using (var context = GetContextWithData()) { var validator = new UpdatePersonCommandValidator(context); validator.ShouldHaveValidationErrorFor(x => x.Name, string.Empty); } }
public void Update_Person_With_Invalid_Email_Throws_Exception() { using (var context = GetContextWithData()) { var validator = new UpdatePersonCommandValidator(context); validator.ShouldHaveValidationErrorFor(x => x.Email, "111"); } }
public void Update_Person_With_Name_That_Already_Exists_Throws_Exception() { using (var context = GetContextWithData()) { var person = context.Persons.FirstOrDefault(b => b.Name == "Victor"); if (person != null) { person.UpdateName("Tunde"); var validator = new UpdatePersonCommandValidator(context); var result = validator.TestValidate(new UpdatePersonCommand { Name = person.Name, Email = person.Email, Id = person.Id, IsAdmin = person.IsAdmin }); result.ShouldHaveValidationErrorFor(x => x); } } }
public void Update_Person_With_Email_That_Does_Not_Already_Exist() { using (var context = GetContextWithData()) { var person = context.Persons.FirstOrDefault(b => b.Name == "Victor"); if (person != null) { person.UpdateEmail("*****@*****.**"); var validator = new UpdatePersonCommandValidator(context); var result = validator.TestValidate(new UpdatePersonCommand { Name = person.Name, Email = person.Email, Id = person.Id, IsAdmin = person.IsAdmin }); result.ShouldNotHaveValidationErrorFor(x => x.Email); } } }