コード例 #1
0
        public void ShouldKnowHowToDeletePage()
        {
            var id         = 1;
            var repository = new Mock <Repository>();
            var controller = new PagesController(repository.Object);
            var result     = (RedirectToRouteResult)controller.Delete(id);

            repository.Verify(it => it.Delete <StaticPage>(id), Times.Once());
            Assert.AreEqual("List", result.RouteValues["action"]);
        }
コード例 #2
0
        public async Task Delete_should_return_no_content()
        {
            // given
            Page expectedPage   = _fixture.Create <Page>();
            int  expectedPageId = expectedPage.Id;

            _pageRepositoryMock
            .DeletePageAsync(expectedPageId)
            .Returns(Task.CompletedTask);

            // when
            ActionResult <string> actionResult = await _pagesController.Delete(expectedPageId);

            // then
            actionResult.ShouldBeNoContentResult();
        }
コード例 #3
0
		public void delete_should_contains_redirect_and_remove_page()
		{
			// Arrange
			Page page1 = AddDummyPage1();
			Page page2 = AddDummyPage2();

			// Act
			ActionResult result = _pagesController.Delete(50);

			// Assert
			Assert.That(result, Is.TypeOf<RedirectToRouteResult>(), "RedirectToRouteResult");
			RedirectToRouteResult redirectResult = result as RedirectToRouteResult;
			Assert.NotNull(redirectResult, "Null RedirectToRouteResult");

			Assert.That(redirectResult.RouteValues["action"], Is.EqualTo("AllPages"));
			_pageServiceMock.Verify(x => x.DeletePage(50));
		}
コード例 #4
0
        public async Task Delete_should_call_repository()
        {
            // given
            Page expectedPage   = _fixture.Create <Page>();
            int  expectedPageId = expectedPage.Id;

            _pageRepositoryMock
            .DeletePageAsync(expectedPageId)
            .Returns(Task.CompletedTask);

            // when
            await _pagesController.Delete(expectedPageId);

            // then
            await _pageRepositoryMock
            .Received(1)
            .DeletePageAsync(expectedPageId);
        }
コード例 #5
0
        public void PageControllerDelete()
        {
            var result = _ctrl.Delete("96d5b379-7e1d-4dac-a6ba-1e50db561b04");

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }