public void GetBookmartkWithInvalidIdSouldReturnNotFound() { var ctrl = new BookmarkController(_dataServiceFacadeMock.Object, null); var response = ctrl.GetBookmark(1, "nm0000015"); response.Should().BeOfType <NotFoundResult>(); }
public void GetBookmartkWithValidIdSouldReturnOk() { _dataServiceFacadeMock.Setup(x => x.BookmarkingDs.GetBookMark(1, "nm0000015")).Returns(new BookmarkPerson()); _mapperMock.Setup(x => x.Map <BookmarkPersonDto>(It.IsAny <BookmarkPerson>())).Returns(new BookmarkPersonDto()); var ctrl = new BookmarkController(_dataServiceFacadeMock.Object, _mapperMock.Object); ctrl.Url = _urlMock.Object; var response = ctrl.GetBookmark(1, "nm0000015"); response.Should().BeOfType <OkObjectResult>(); }
public async Task GetBookmark_ValidBookmarkId_NotFound() { int testBookmarkPostID = -1; var mapper = MapperCollectionExtension.CreateMapper(); var dataService = new Mock <IBookmarkRepository>(); dataService .Setup(repo => repo.Get(testBookmarkPostID)) .Returns(Task.FromResult((Bookmark)null)); var urlHelper = new Mock <IUrlHelper>(); var controller = new BookmarkController(dataService.Object, mapper); controller.Url = urlHelper.Object; var result = await controller.GetBookmark(testBookmarkPostID); Assert.IsType <NotFoundResult>(result); dataService.Verify(x => x.Get(testBookmarkPostID)); }