public void Execute_WhenInputMessageContainsValidData_ShouldUpdateItem() { //---------------Arrange------------------- var itemModel = CreateValidUpdateMessage("Updated task"); var testContext = new UpdateTodoItemUseCaseTestDataBuilder().Build(); var usecase = testContext.UseCase; var presenter = new ResultFreePropertyPresenter <ErrorOutputMessage>(); //---------------Act------------------- usecase.Execute(itemModel, presenter); //---------------Assert------------------- Assert.IsFalse(presenter.IsErrorResponse()); testContext.Repository.Received(1).Update(Arg.Is <UpdateTodoInput>(x => x.Id == itemModel.Id)); testContext.Repository.Received(1).Persist(); }
public void Execute_WhenEmptyOrWhitespaceItemDescription_ShouldReturnErrorMessage(string itemDescription) { //---------------Arrange------------------- var expected = "ItemDescription cannot be null or empty"; var itemModel = CreateValidUpdateMessage(itemDescription); var testContext = new UpdateTodoItemUseCaseTestDataBuilder().Build(); var usecase = testContext.UseCase; var presenter = new ResultFreePropertyPresenter <ErrorOutputMessage>(); //---------------Act------------------- usecase.Execute(itemModel, presenter); //---------------Assert------------------- Assert.IsTrue(presenter.ErrorContent.HasErrors); Assert.AreEqual(expected, presenter.ErrorContent.Errors.First()); }