public CreateCategoryCommand(string descricao) { Descricao = descricao; var validator = new CreateCategoryCommandValidator(); Validation = validator.Validate(this); }
public void IsValid_ShouldBeTrue_WhenListTitleIsUnique() { var command = new CreateCategoryCommand { CategoryName = "Food 2" }; var validator = new CreateCategoryCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(true); }
public void IsValid_ShouldBeFalse_WhenListTitleIsNotUnique() { Context.Categories.Add(new Category { CategoryName = "Shopping" }); Context.SaveChanges(); var command = new CreateCategoryCommand { CategoryName = "Shopping" }; var validator = new CreateCategoryCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(false); }