public void IsValid_ShouldBeTrue_WhenListTitleIsUnique() { var command = new CreateTodoListCommand { Title = "Bucket List" }; var validator = new CreateTodoListCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(true); }
public void IsValid_ShouldBeFalse_WhenListTitleIsNotUnique() { var command = new CreateTodoListCommand { Title = "Death List Five" }; var validator = new CreateTodoListCommandValidator(_context); var result = validator.Validate(command); result.IsValid.ShouldBeFalse(); }
public void IsValid_ShouldBeTrue_WhenListTitleIsUnique() { var command = new CreateTodoListCommand { Title = "Bucket List", }; var validator = new CreateTodoListCommandValidator(_context); var result = validator.Validate(command); // TODO: Need to check that the unique title rule is valid, even though other rules may have failed. result.IsValid.ShouldBe(true); }
public void IsValid_ShouldBeFalse_WhenListTitleIsNotUnique() { var command = new CreateTodoListCommand { Title = "Todo List" }; var validator = new CreateTodoListCommandValidator(_context); var result = validator.Validate(command); result.IsValid.ShouldBe(false); result.Errors[0].PropertyName.ShouldBe("Title"); result.Errors[0].ErrorMessage.ShouldBe("The specified title already exists."); }
public void IsValid_ShouldBeFalse_WhenListTitleIsNotUnique() { Context.TodoLists.Add(new TodoList { Title = "Shopping" }); Context.SaveChanges(); var command = new CreateTodoListCommand { Title = "Shopping" }; var validator = new CreateTodoListCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(false); }
public void IsValid_ShouldBeFalse_WhenListTitleIsNotUnique() { var command = new CreateTodoListCommand { Title = "Todo List" }; var validator = new CreateTodoListCommandValidator(Context); var result = validator.Validate(command); // NOTE: An assumption is made that this has failed, because the title is not unique. result.IsValid.ShouldBe(false); //result.Errors // .Any(e => e.PropertyName == "Title" && e.ErrorMessage == "The specified 'Title' already exists.") // .ShouldBeTrue(); }
public void ShouldNotAllowEmptyTitle() { var validationResults = _createCommandValidator.Validate(new CreateTodoListCommand()); validationResults.Errors.Count.Should().BeGreaterOrEqualTo(1); }