Esempio n. 1
0
        public void GetImageById_ReturnsNotFoundResult_WhenUserNotFound()
        {
            // Arrange
            int testImageId = 5;

            mockRepo.Setup(repo => repo.GetImageById(testImageId))
            .Returns(null as Image);
            var controller = new ImagesController(mockRepo.Object, mockGCS.Object, mockMapper.Object);

            // Act
            var result = controller.GetImageById(testImageId);

            // Assert
            Assert.IsType <NotFoundResult>(result.Result);
        }
Esempio n. 2
0
        public void GetImageById_ReturnsokObjectResult_WithImage()
        {
            // Arrange
            int testImageId = 1;
            var testImage   = new Image {
                Id = 1, Url = "google.com/image2", Name = "image2"
            };

            mockRepo.Setup(repo => repo.GetImageById(testImageId))
            .Returns(testImage);

            var controller = new ImagesController(mockRepo.Object, mockGCS.Object, mockMapper.Object);

            // Act
            var result = controller.GetImageById(testImageId);

            // Assert
            var okObjectResult = Assert.IsType <OkObjectResult>(result.Result);

            Assert.Same(testImage, okObjectResult.Value);
        }