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_WhenIdExist_ShouldReturnEmptyResponse() { //---------------Arrange------------------- var id = Guid.NewGuid(); var presenter = new ResultFreePropertyPresenter <ErrorOutputMessage>(); var testContext = new DeleteTodoItemUseCaseTestDataBuilder().WithDeleteResult(true).Build(); var usecase = testContext.UseCase; var message = new DeleteTodoInput { Id = id }; //---------------Act------------------- usecase.Execute(message, presenter); //---------------Assert------------------- Assert.IsFalse(presenter.IsErrorResponse()); testContext.Repository.Received(1).Persist(); }