public async Task Update_should_update_using_repository_and_return_pageresponse() { // given var pageRequest = new PageRequest() { Id = 88, Title = "new title" }; var changedPage = new Page() { Id = pageRequest.Id, Title = pageRequest.Title }; var expectedResponse = new PageResponse() { Id = pageRequest.Id, Title = pageRequest.Title }; _pageRepositoryMock .UpdateExistingAsync(Arg.Any <Page>()) .Returns(changedPage); // when ActionResult <PageResponse> actionResult = await _pagesController.Update(pageRequest); // then await _pageRepositoryMock .Received(1) .UpdateExistingAsync(Arg.Is <Page>(page => page.Id == changedPage.Id)); actionResult.Value.ShouldNotBeNull("ActionResult's model was null"); actionResult.Value.ShouldBeEquivalent(expectedResponse); }
public async Task Update_should_return_pageresponse() { // given var pageRequest = new PageRequest() { Id = 88, Title = "new title" }; var changedPage = new Page() { Id = pageRequest.Id, Title = pageRequest.Title }; var expectedResponse = new PageResponse() { Id = pageRequest.Id, Title = pageRequest.Title }; _pageRepositoryMock .UpdateExistingAsync(Arg.Any <Page>()) .Returns(changedPage); // when ActionResult <PageResponse> actionResult = await _pagesController.Update(pageRequest); // then actionResult.ShouldBeNoContentResult(); }
public void PageControllerUpdate() { var result = _ctrl.Update(new PageDetail() { Id = Guid.NewGuid() }); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); }