public void Get_GetByIdIfAuthorDontHavePublications_NotFound404() { // Arrange var getPublication = new Mock <IGetablePublication>(); var mapper = new Mock <IMapper>(); var adminPublicationController = new AdminPublicationController( getPublication.Object, mapper.Object); getPublication.Setup(gp => gp.GetAllByAuthorId(_publication.Author.Id)) .Throws(new ObjectNotFoundException("Author dont have a publications.")); // Act var result = adminPublicationController.GetAllByAuthor(_publication.Author.Id); // Assert Assert.IsType <NotFoundObjectResult>(result.Result); }
public void GetAllByAuthorId_GetAllByAuthorId_Publications_OkObjectResult() { // Arrange var getablePublication = new Mock <IGetablePublication>(); var mapper = new Mock <IMapper>(); getablePublication.Setup(gp => gp.GetAllByAuthorId(_publicationEntities.ElementAt(0).Author.Id)) .Returns(_publicationEntities); mapper.Setup(m => m.Map <PublicationDTO>(_publicationEntities.ElementAt(0))) .Returns(_publicationsDTO.ElementAt(0)); var adminPublicationController = new AdminPublicationController( getablePublication.Object, mapper.Object); // Act var result = adminPublicationController.GetAllByAuthor(_publicationEntities.ElementAt(0).Author.Id); // Assert Assert.NotNull(adminPublicationController); Assert.NotNull(result); Assert.IsType <OkObjectResult>(result.Result); }