public void Create_Planet_With_No_Introduction_Throws_Exception() { using (var context = GetContextWithData()) { var validator = new CreatePlanetCommandValidator(context); validator.ShouldHaveValidationErrorFor(x => x.Introduction, string.Empty); } }
public void Create_Planet_With_Title_That_Does_Not_Already_Exists() { using (var context = GetContextWithData()) { var validator = new CreatePlanetCommandValidator(context); var result = validator.TestValidate(new CreatePlanetCommand { Id = new Guid(), Name = Name }); result.ShouldNotHaveValidationErrorFor(x => x.Name); } }
public void Create_Planet_With_Name_That_Already_Exists_Throws_Exception() { using (var context = GetContextWithData()) { var validator = new CreatePlanetCommandValidator(context); var name = context.Planets.FirstOrDefault()?.Name; if (name == null) { return; } var result = validator.TestValidate(new CreatePlanetCommand { Id = new Guid(), Name = name }); result.ShouldHaveValidationErrorFor(x => x); } }