public void GetAuthorCount_GetAuthorCountIfPublicationFound_OkObjectResult() { // Arrange var getableFavorite = new Mock <IGetableFavorite>(); var mapper = new Mock <IMapper>(); var favoriteController = new FavoriteController( getableFavorite.Object, mapper.Object); // Act var result = favoriteController.GetAuthorCount(Guid.NewGuid()); // Assert Assert.NotNull(result); Assert.IsType <OkObjectResult>(result.Result); }
public void GetAuthorCount_GetAuthorCountIfPublictionNotFound_NotFound404() { // Arrange var invalidPublicationId = Guid.NewGuid(); var getableFavorite = new Mock <IGetableFavorite>(); var mapper = new Mock <IMapper>(); var favoriteController = new FavoriteController( getableFavorite.Object, mapper.Object); getableFavorite.Setup(gf => gf.GetAuthorCount(invalidPublicationId)) .Throws(new ObjectNotFoundException("Publication not found.")); // Act var result = favoriteController.GetAuthorCount(invalidPublicationId); // Assert Assert.NotNull(result); Assert.IsType <NotFoundObjectResult>(result.Result); }
public void GetAuthorCount_GetAuthorCountIfPublicationDontHaveFavorites_OkObjectResult() { // Arrange var getableFavorite = new Mock <IGetableFavorite>(); var mapper = new Mock <IMapper>(); var favoriteController = new FavoriteController( getableFavorite.Object, mapper.Object); var validPublicationId = Guid.NewGuid(); getableFavorite.Setup(gf => gf.GetAuthorCount(validPublicationId)) .Throws(new FavoritesNotFoundException("Favorites not found")); // Act var result = favoriteController.GetAuthorCount(validPublicationId); // Assert Assert.NotNull(result); Assert.IsType <OkObjectResult>(result.Result); Assert.Equal(0, result.Value); }