public async Task DownloadMultiple_Returns_BadRequest_When_DocumentLibraryIdIsNull() { // Arrange var body = "{\"driveItems\": [\"01EIR2WX4I7ZPREEQDMZG3SNTMBTLFBTID\", \"01EIR2WX4I7ZPREEQDMZG3SNTMBTLFBTID\"]}"; var reqMock = TestFactory.CreateHttpRequestMock(body); // Act var httpActionResult = await _sut.DownloadMultiple(reqMock.Object, null, _logger); // Assert Assert.IsInstanceOf(typeof(BadRequestObjectResult), httpActionResult); }
public async Task DownloadMultiple_Returns_BadRequest_When_DriveItemIdIsNull() { // Arrange var documentLibraryId = SettingsHelper.DocumentLibraryId; var body = "{\"driveItems\": [null]}"; var reqMock = TestFactory.CreateHttpRequestMock(body); var logger = TestFactory.CreateLogger(LoggerTypes.List); // Act var httpActionResult = await _sut.DownloadMultiple(reqMock.Object, documentLibraryId, logger); // Assert Assert.IsInstanceOf(typeof(BadRequestObjectResult), httpActionResult); }
public async Task DownloadMultiple_Returns_BadRequest_When_DriveItemIdIsEmpty() { // Arrange var documentLibraryId = "DL1"; var body = "{\"driveItems\": [\"\"]}"; var reqMock = TestFactory.CreateHttpRequestMock(body); var logger = TestFactory.CreateLogger(LoggerTypes.List); // Act var httpActionResult = await _controller.DownloadMultiple(reqMock.Object, documentLibraryId, logger); // Assert _fileServiceMock.Verify(x => x.DownloadAsync(It.Is <string>(p => p == "siteId"), It.Is <string>(p => p == documentLibraryId), It.IsAny <string>()), Times.Never); Assert.IsInstanceOf(typeof(BadRequestObjectResult), httpActionResult); }
public async Task DownloadMultiple_Returns_BadRequest_When_DriveItemIdIsEmpty() { // Arrange var documentLibraryId = SettingsHelper.DocumentLibraryId; var driveItemId = string.Empty; var body = "{\"driveItems\": [\"\"]}"; var reqMock = TestFactory.CreateHttpRequestMock(body); // Act var httpActionResult = await _sut.Download(reqMock.Object, documentLibraryId, driveItemId, _logger); // Assert Assert.IsInstanceOf(typeof(BadRequestObjectResult), httpActionResult); }
public async Task DownloadMultiple_Returns_Files_When_Found() { // Arrange var body = "{\"driveItems\": [\"01EIR2WX4I7ZPREEQDMZG3SNTMBTLFBTID\", \"01EIR2WX4I7ZPREEQDMZG3SNTMBTLFBTID\"]}"; var reqMock = TestFactory.CreateHttpRequestMock(body); var documentLibraryId = SettingsHelper.DocumentLibraryId; // Act var httpActionResult = await _sut.DownloadMultiple(reqMock.Object, documentLibraryId, _logger); // Assert Assert.IsInstanceOf(typeof(FileContentResult), httpActionResult); }
public async Task DownloadMultiple_Returns_Files_When_Found() { // Arrange var documentLibraryId = "DL1"; var body = "{\"driveItems\": [\"DI1\", \"DI2\"]}"; var reqMock = TestFactory.CreateHttpRequestMock(body); var logger = TestFactory.CreateLogger(LoggerTypes.List); _fileServiceMock.Setup(x => x.DownloadAsync(It.Is <string>(p => p == "siteId"), It.Is <string>(x => x == documentLibraryId), It.Is <string>(x => x == "DI1"))).ReturnsAsync(DownloadResult.Success("DI1", "File1.docx", new byte[] { 0x01, 0x01, 0x01 })); _fileServiceMock.Setup(x => x.DownloadAsync(It.Is <string>(p => p == "siteId"), It.Is <string>(x => x == documentLibraryId), It.Is <string>(x => x == "DI2"))).ReturnsAsync(DownloadResult.Success("DI2", "File2.docx", new byte[] { 0x02, 0x02, 0x02 })); // Act var httpActionResult = await _controller.DownloadMultiple(reqMock.Object, documentLibraryId, logger); // Assert _fileServiceMock.Verify(x => x.DownloadAsync(It.Is <string>(p => p == "siteId"), It.Is <string>(x => x == documentLibraryId), It.Is <string>(x => x == "DI1")), Times.Once); _fileServiceMock.Verify(x => x.DownloadAsync(It.Is <string>(p => p == "siteId"), It.Is <string>(x => x == documentLibraryId), It.Is <string>(x => x == "DI2")), Times.Once); Assert.IsInstanceOf(typeof(FileContentResult), httpActionResult); }