public async Task Update_UpdateIfPublicationNotFound_NotFound404()
        {
            // Arrange
            var editPublication = new Mock <IEditablePublicationAsync>();
            var getPublication  = new Mock <IGetablePublication>();
            var mapper          = new Mock <IMapper>();

            var adminPublicationController = new AdminPublicationController(
                editPublication.Object,
                getPublication.Object,
                mapper.Object);

            getPublication.Setup(gp => gp.GetById(_updatePublicationDTO.Id))
            .Throws(new ObjectNotFoundException("Publication not found."));

            // Act
            var result = await adminPublicationController.Update(_updatePublicationDTO);

            // Assert
            Assert.IsType <NotFoundObjectResult>(result.Result);
        }
Esempio n. 2
0
        public async Task Update_UpdatePublication_OkObjectResult()
        {
            // Arrange
            var editablePublication = new Mock <IEditablePublicationAsync>();
            var getablePublication  = new Mock <IGetablePublication>();
            var mapper = new Mock <IMapper>();

            getablePublication.Setup(ep => ep.GetById(_publicationEntities.ElementAt(0).Id))
            .Returns(_publicationEntities.ElementAt(0));

            var adminPublicationController = new AdminPublicationController(
                editablePublication.Object,
                getablePublication.Object,
                mapper.Object);

            // Act
            var result = await adminPublicationController.Update(_updatePublicationDTO);

            // Assert
            Assert.NotNull(adminPublicationController);
            Assert.NotNull(result);
            Assert.IsType <OkObjectResult>(result.Result);
        }