public async void Should_UploadEnd_Fail_400_With_No_Data() { var request = TestFactory.CreateHttpRequest("none", "nil"); var uploadDir = _app.Repository.GetBlobDirectory(BlobNames.UploadDirectory + "/test"); var uploadTmpTable = _app.Repository.GetTable(TableNames.CommUpload); var queue = _app.Repository.GetQueue(QueueNames.CommProcess); var tmpUploadEntity = new TableEntityAdapter <UploadSession>( new UploadSession { SessionId = "test" }, "test", new IdGenerator().UploadSessionId()); // call Azure Function var response = (ObjectResult)await UploadFunctions.End(request, "test", $"{DateTime.Now:u} Sample 2.pdf", uploadDir, tmpUploadEntity, uploadTmpTable, queue, _app.App, _logger); var upload = response.Value.IsOrMap <UploadSession>(); Assert.Equal(StatusCodes.Status400BadRequest, response.StatusCode); Assert.Null(upload.ManifestFile); Assert.Null(upload.LastUploadedFile); Assert.Null(upload.UploadEnd); _output.WriteLine(upload.ToJson(Formatting.Indented)); }
public async void Should_Upload_Completed_With_Manifest_Last() { var request = TestFactory.CreateHttpRequestWithDataStream($"Data/Sample 2.pdf"); var uploadDir = _app.Repository.GetBlobDirectory(BlobNames.UploadDirectory); var uploadTmpTable = _app.Repository.GetTable(TableNames.CommUpload); var queue = _app.Repository.GetQueue(QueueNames.CommProcess); // call step1 upload start var response = (ObjectResult)await UploadFunctions.Start(request, $"{DateTime.Now:u} Sample 2.pdf", uploadDir, uploadTmpTable, new IdGenerator(), _app.App, _logger); var upload = response.Value.IsOrMap <UploadSession>(); Assert.Equal(StatusCodes.Status200OK, response.StatusCode); Assert.Null(upload.ManifestFile); Assert.NotNull(upload.UploadStart); Assert.Null(upload.UploadEnd); Assert.Contains("Sample 2.pdf", upload.LastUploadedFile); _output.WriteLine(upload.ToJson(Formatting.Indented)); // call step2 upload continue var sessionId = upload.SessionId; var sessionBlobDirectory = _app.Repository.GetBlobDirectory(BlobNames.UploadDirectory + $"/{sessionId}"); var tmpEntity = new TableEntityAdapter <UploadSession>(upload, CommUploadPartitionKeys.Temp, sessionId); request = TestFactory.CreateHttpRequestWithDataStream("Data/Sample 1.pdf"); response = (ObjectResult)await UploadFunctions.Continue(request, sessionId, $"{DateTime.Now:u} Sample 1.pdf", sessionBlobDirectory, tmpEntity, uploadTmpTable, _logger); upload = response.Value.IsOrMap <UploadSession>(); Assert.Equal(StatusCodes.Status200OK, response.StatusCode); Assert.Null(upload.ManifestFile); Assert.NotNull(upload.UploadStart); Assert.Null(upload.UploadEnd); Assert.Contains("Sample 1.pdf", upload.LastUploadedFile); _output.WriteLine(upload.ToJson(Formatting.Indented)); // call step3 upload end tmpEntity = new TableEntityAdapter <UploadSession>(upload, CommUploadPartitionKeys.Temp, sessionId); request = TestFactory.CreateHttpRequestWithDataStream($"Data/{CommunicationManifest.FileName}"); response = (ObjectResult)await UploadFunctions.End(request, sessionId, CommunicationManifest.FileName, sessionBlobDirectory, tmpEntity, uploadTmpTable, queue, _app.App, _logger); upload = response.Value.IsOrMap <UploadSession>(); Assert.Equal(StatusCodes.Status200OK, response.StatusCode); Assert.NotNull(upload.ManifestFile); Assert.NotNull(upload.UploadStart); Assert.NotNull(upload.UploadEnd); Assert.Contains(CommunicationManifest.FileName, upload.LastUploadedFile); _output.WriteLine(upload.ToJson(Formatting.Indented)); }