public async void Test_Controller_Delete()
        {
            var resultFail = await _controller.Delete(0);

            var resultPass = await _controller.Delete(1);

            Assert.NotNull(resultFail);
            Assert.NotNull(resultPass);
        }
Beispiel #2
0
        public async Task TestDeleteRemovalSuccessTrue()
        {
            // Arrange
            var fileName = "test.jpg";

            var media = new Media();

            var mockMediaService = new Mock <IMediaService>();

            mockMediaService
            .Setup(x => x.RemoveAzureBlobMediaObjectAsync(It.IsAny <Media>()))
            .ReturnsAsync(true);

            mockMediaService
            .Setup(x => x.GetMediaByFileNameAsync(It.IsAny <string>()))
            .ReturnsAsync(media);

            var controller = new MediaController(mockMediaService.Object);

            // Act
            var result = await controller.Delete(fileName);

            // Assert
            Assert.IsAssignableFrom <OkResult>(result);
        }
Beispiel #3
0
        public async Task TestDeleteFileNameNull()
        {
            // Arrange
            var controller = new MediaController(null);

            // Act
            var result = await controller.Delete(null);

            // Assert
            Assert.IsAssignableFrom <BadRequestResult>(result);
        }
Beispiel #4
0
        public async Task TestDeleteFileNameInvalid()
        {
            // Arrange
            var fileName = "test.jpg";

            Media media = null;

            var mockMediaService = new Mock <IMediaService>();

            mockMediaService
            .Setup(x => x.GetMediaByFileNameAsync(It.IsAny <string>()))
            .ReturnsAsync(media);

            var controller = new MediaController(mockMediaService.Object);

            // Act
            var result = await controller.Delete(fileName);

            // Assert
            Assert.IsAssignableFrom <NotFoundResult>(result);
        }