Esempio n. 1
0
        public async Task DownloadBookSuccess()
        {
            //Arrange
            var mockStream = new Mock <Stream>();

            var fileServiceMock = new Mock <IBookService>();

            fileServiceMock.Setup(m => m.GetBookForUserAsync(It.IsAny <string>(), It.IsAny <int>()))
            .Returns(Task.FromResult(new Book()
            {
                Id = 1
            }));
            fileServiceMock.Setup(m => m.DownloadBookAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>()))
            .Returns(Task.FromResult(mockStream.Object));
            var storageMock = new Mock <IStorageService>();

            var fileController = new BookController(_mapper, fileServiceMock.Object, _logger, storageMock.Object);

            //Act

            IActionResult actionResult = await fileController.DownloadBook("ID1", 1);

            actionResult.ShouldNotBeNull();

            OkObjectResult result = actionResult as OkObjectResult;

            result.ShouldNotBeNull();
        }