Esempio n. 1
0
        public void Execute_WhenInvalidTodoItemId_ShouldReturnError()
        {
            //---------------Arrange-------------------

            var testContext = new DeleteCommentUseCaseTestDataBuilder()
                              .WithDeleteResult(true)
                              .Build();
            var usecase = testContext.UseCase;
            var input   = new DeleteCommentInput {
                Id = Guid.Empty
            };
            var presenter = CreatePropertyPresenter();

            //---------------Act----------------------
            usecase.Execute(input, presenter);
            //---------------Assert-----------------------
            Assert.IsTrue(presenter.ErrorContent.HasErrors);
            Assert.AreEqual("Invalid comment Id", presenter.ErrorContent.Errors[0]);
        }
Esempio n. 2
0
        public void Execute_WhenTodoItemIdNotFound_ShouldReturnError()
        {
            //---------------Arrange-------------------

            var testContext = new DeleteCommentUseCaseTestDataBuilder()
                              .WithDeleteResult(false)
                              .Build();
            var usecase = testContext.UseCase;
            var id      = Guid.NewGuid();
            var input   = new DeleteCommentInput {
                Id = id
            };
            var presenter = CreatePropertyPresenter();

            //---------------Act----------------------
            usecase.Execute(input, presenter);
            //---------------Assert-----------------------
            Assert.IsTrue(presenter.ErrorContent.HasErrors);
            Assert.AreEqual("Could not locate item Id", presenter.ErrorContent.Errors[0]);
        }
Esempio n. 3
0
        public void Execute_WhenValidTodoItemId_ShouldReturnSuccess()
        {
            //---------------Arrange-------------------
            var id = Guid.NewGuid();

            var testContext = new DeleteCommentUseCaseTestDataBuilder()
                              .WithDeleteResult(true)
                              .Build();
            var usecase = testContext.UseCase;

            var input = new DeleteCommentInput {
                Id = id
            };
            var presenter = CreatePropertyPresenter();

            //---------------Act----------------------
            usecase.Execute(input, presenter);
            //---------------Assert-----------------------
            Assert.IsFalse(presenter.IsErrorResponse());
            testContext.Repository.Received(1).MarkForDelete(Arg.Is <Guid>(x => x == id));
            testContext.Repository.Received(1).Persist();
        }