public void should_download_pdf_format() { // arrange var info = new DocumentHandleInfo( new DocumentHandle("doc"), new FileNameWithExtension("a.file") ); var format = new DocumentFormat("pdf"); var pdfBlobId = new BlobId("pdf"); var doc = new DocumentDescriptorReadModel( 1L, new DocumentDescriptorId(1), new BlobId("file_1")); doc.AddFormat(new PipelineId("abc"), format, pdfBlobId); SetupDocumentHandle(info, doc.Id); SetupDocumentModel(doc); BlobStore.GetDescriptor(pdfBlobId).Returns(i => new FsBlobDescriptor(pdfBlobId, TestConfig.PathToDocumentPdf)); // act using (var response = Controller.GetFormat(_tenantId, info.Handle, format)) { // assert response.EnsureSuccessStatusCode(); Assert.AreEqual("application/pdf", response.Content.Headers.ContentType.MediaType); } }
public void verify_handle_linked_to_document_with_formats() { SetHandleToReturn(); IBlobDescriptor stub = Substitute.For <IBlobDescriptor>(); stub.FileNameWithExtension.Returns(new FileNameWithExtension("test.txt")); _blobStore.GetDescriptor(Arg.Any <BlobId>()).Returns(stub); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); docRm.AddFormat(new PipelineId("tika"), new DocumentFormat("blah"), new BlobId("pdf")); docRm.AddFormat(new PipelineId("test"), new DocumentFormat("blah blah"), new BlobId("test")); docRm.Created = true; rmDocuments.Add(docRm); CreateSut(); var evt = new DocumentLinked(new DocumentHandle("rev_1"), new DocumentDescriptorId(1), new DocumentDescriptorId(2), new FileNameWithExtension("test.txt")); _sut.Handle(evt, false); //I'm expecting new format added to handle Assert.That(rmStream, Has.Count.EqualTo(3)); Assert.That(rmStream[0].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[0].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[0].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("original")); Assert.That(rmStream[0].Filename.FileName, Is.EqualTo("test")); Assert.That(rmStream[0].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[1].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[1].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[1].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("blah")); Assert.That(rmStream[1].Filename.FileName, Is.EqualTo("test")); Assert.That(rmStream[1].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[2].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[2].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[2].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("blah blah")); Assert.That(rmStream[2].Filename.FileName, Is.EqualTo("test")); Assert.That(rmStream[2].Filename.Extension, Is.EqualTo("txt")); }
public void should_download_pdf_format() { // arrange var info = new DocumentHandleInfo( new DocumentHandle("doc"), new FileNameWithExtension("a.file") ); var format = new DocumentFormat("pdf"); var pdfBlobId = new BlobId("pdf"); var doc = new DocumentDescriptorReadModel( 1L, new DocumentDescriptorId(1), new BlobId("file_1")); doc.AddFormat(new PipelineId("abc"), format, pdfBlobId); SetupDocumentHandle(info, doc.Id); SetupDocumentModel(doc); BlobStore.GetDescriptor(pdfBlobId).Returns(i => new FsBlobDescriptor(pdfBlobId, TestConfig.PathToDocumentPdf)); // act using (var response = Controller.GetFormat(_tenantId, info.Handle, format).Result) { // assert response.EnsureSuccessStatusCode(); Assert.AreEqual("application/pdf", response.Content.Headers.ContentType.MediaType); } }
public void verify_handle_linked_to_document_with_formats() { SetHandleToReturn(); IBlobDescriptor stub = Substitute.For<IBlobDescriptor>(); stub.FileNameWithExtension.Returns(new FileNameWithExtension("test.txt")); _blobStore.GetDescriptor(Arg.Any<BlobId>()).Returns(stub); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); docRm.AddFormat(new PipelineId("tika"), new DocumentFormat("blah"), new BlobId("pdf")); docRm.AddFormat(new PipelineId("test"), new DocumentFormat("blah blah"), new BlobId("test")); docRm.Created = true; rmDocuments.Add(docRm); CreateSut(); var evt = new DocumentLinked(new DocumentHandle("rev_1"), new DocumentDescriptorId(1), new DocumentDescriptorId(2), new FileNameWithExtension("test.txt")); _sut.Handle(evt, false); //I'm expecting new format added to handle Assert.That(rmStream, Has.Count.EqualTo(3)); Assert.That(rmStream[0].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[0].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[0].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("original")); Assert.That(rmStream[0].Filename.FileName, Is.EqualTo("test")); Assert.That(rmStream[0].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[1].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[1].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[1].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("blah")); Assert.That(rmStream[1].Filename.FileName, Is.EqualTo("test")); Assert.That(rmStream[1].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[2].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[2].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[2].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("blah blah")); Assert.That(rmStream[2].Filename.FileName, Is.EqualTo("test")); Assert.That(rmStream[2].Filename.Extension, Is.EqualTo("txt")); }