// [Test] public void TestPdfDoesntOverwriteOtherFileWithSameName() { var attachment = new ProtectAttachment(TestUtils.CreateAttachment("FilesWithSameName.zip", "FilesWithSameName.zip", "1")); var attachments = new ObservableCollection<IProtectAttachment>() { attachment }; var actionQueue = new ActionQueue(); bool discoveryCompleted = false; bool appliedAllActions = false; actionQueue.StatusUpdate += (sender, args) => { if (args.Status == PropertyNames.DiscoveryCompleted) { discoveryCompleted = true; } if (args.Status == PropertyNames.AppliedAllActions) { appliedAllActions = true; } }; actionQueue.Discover(attachments.ToList()); SpinWait.SpinUntil(() => discoveryCompleted, 90000); Assert.IsTrue(discoveryCompleted, "Discovery failed to complete."); var xlsx = attachment.Children.First(x => x.FileName.Contains(".xlsx")); var options = new Dictionary<string, dynamic> {{PropertyNames.PdfFormat, PropertyValues.PdfA}}; var pdf = WorkshareTaskFactory.CreatePdfTask(xlsx, options); var task = new TaskRepack(attachments); actionQueue.ApplyTasks(new List<IWorkshareTask>() { pdf, task }); SpinWait.SpinUntil(() => appliedAllActions, 90000); Assert.IsTrue(appliedAllActions, "Failed to apply all actions within the time limit"); new Workshare.API.Cleaning.OfficeApplicationCacheControl().ReleaseOfficeApplications(); VerifyFilesAreNotEqual(attachment.FileName); SpinWait.SpinUntil(TestUtils.HasOfficeShutDown, 60000); }
//[Test] public void TestExpandRepackMaintainsDirectoryStructure_03() // Bug fix { var zipAttachment = new ProtectAttachment(TestUtils.CreateAttachment("small.zip", "small.zip", "1")); var expectedDirectoryStructure = GetZipFileDirectoryStructure(zipAttachment.FileName); var attachments = new ObservableCollection<IProtectAttachment>() { zipAttachment }; var actionQueue = new ActionQueue(); bool discoveryCompleted = false; bool appliedAllActions = false; actionQueue.StatusUpdate += (sender, args) => { if (args.Status == PropertyNames.DiscoveryCompleted) { discoveryCompleted = true; } if (args.Status == PropertyNames.AppliedAllActions) { appliedAllActions = true; } }; actionQueue.Discover(attachments.ToList()); SpinWait.SpinUntil(() => discoveryCompleted, 90000); Assert.IsTrue(discoveryCompleted); var options = new Dictionary<string, dynamic> { { PropertyNames.PdfFormat, PropertyValues.PdfA } }; var tasks = WorkshareTaskFactory.Create(attachments, options, null); actionQueue.ApplyTasks(tasks); SpinWait.SpinUntil(() => appliedAllActions, 120000); Assert.IsTrue(appliedAllActions, "Failed to apply all actions within the time limit"); var flattenedList = TestUtils.Flatten(zipAttachment.Children, new List<FileType>() { FileType.Email }); foreach (var item in flattenedList) { Assert.IsTrue(item.FileType == FileType.PDFDocument); } zipAttachment.Children.Clear(); VerifyFilesAreOfType(zipAttachment, FileType.PDFDocument); var currentStructure = GetZipFileDirectoryStructure(zipAttachment.FileName); var result = expectedDirectoryStructure.Except(currentStructure).ToList(); Assert.IsTrue(result.Count == 0); new Workshare.API.Cleaning.OfficeApplicationCacheControl().ReleaseOfficeApplications(); SpinWait.SpinUntil(TestUtils.HasOfficeShutDown, 60000); }
// [Test] public void TestConvertCollectionToPdf_02() // Another bug fix { var zipAttachment = new ProtectAttachment(TestUtils.CreateAttachment("small.zip", "small.zip", "1")); var passwordAttachment = new ProtectAttachment(TestUtils.CreateAttachment("password.docx", "password.docx", "1")); var attachments = new ObservableCollection<IProtectAttachment>() { passwordAttachment, zipAttachment }; var actionQueue = new ActionQueue(); bool discoveryCompleted = false; bool appliedAllActions = false; actionQueue.StatusUpdate += (sender, args) => { if (args.Status == PropertyNames.DiscoveryCompleted) { discoveryCompleted = true; } if (args.Status == PropertyNames.AppliedAllActions) { appliedAllActions = true; } }; actionQueue.Discover(attachments.ToList()); SpinWait.SpinUntil(() => discoveryCompleted, 90000); Assert.IsTrue(discoveryCompleted, "Discovery failed to complete."); var options = new Dictionary<string, dynamic> { { PropertyNames.PdfFormat, PropertyValues.PdfA } }; var tasks = WorkshareTaskFactory.Create(attachments, options, null); actionQueue.ApplyTasks(tasks); SpinWait.SpinUntil(() => appliedAllActions, 120000); Assert.IsTrue(appliedAllActions, "Failed to apply all actions within the time limit"); var flattenedList = TestUtils.Flatten(zipAttachment.Children, new List<FileType>() { FileType.Email }); foreach (var item in flattenedList) { Assert.IsTrue(item.FileType == FileType.PDFDocument); } zipAttachment.Children.Clear(); VerifyFilesAreOfType(zipAttachment, FileType.PDFDocument); new Workshare.API.Cleaning.OfficeApplicationCacheControl().ReleaseOfficeApplications(); SpinWait.SpinUntil(TestUtils.HasOfficeShutDown, 60000); }