Exemple #1
0
        public void TestAutoSave_SingleOutputFile_EnsureUniqueFilenameIsDisabled_OutputFilenameDoesExist_ExistingFileGetsOverwritten()
        {
            _th.GenerateGsJob(PSfiles.PDFCreatorTestpage, OutputFormat.Pdf);
            _th.Job.Profile.AutoSave.Enabled = true;

            _settings = new PdfCreatorSettings(null);
            _settings.ConversionProfiles.Add(_th.Job.Profile);
            _settings.ConversionProfiles[0].AutoSave.EnsureUniqueFilenames = false;
            _settings.ConversionProfiles[0].AutoSave.TargetDirectory       = _th.TmpTestFolder;
            _settings.ConversionProfiles[0].FileNameTemplate = "AutoSaveTestOutput";
            _settings.ConversionProfiles[0].OutputFormat     = OutputFormat.Pdf;

            //create empty file, that should be overwritten
            var expectedOutputFile = Path.Combine(_th.TmpTestFolder, "AutoSaveTestOutput.pdf");

            CreateFile(expectedOutputFile);

            var autoSaveWorkflow = new AutoSaveWorkflow(_th.Job, _settings);

            autoSaveWorkflow.RunWorkflow();

            Assert.IsTrue(File.Exists(expectedOutputFile), "Expected outputfile does not exist.");

            var fileInfo = new FileInfo(expectedOutputFile);

            Assert.IsFalse(fileInfo.Length == 0, "Expected outputfile did not overwritte existing (empty) file.");
        }
Exemple #2
0
        public void TestAutoSave_SingleOutputFile_EnsureUniqueFilenameIsEnabled_OutputFilenameDoesExist_OutputfileGetsAppendix()
        {
            _th.GenerateGsJob(PSfiles.PDFCreatorTestpage, OutputFormat.Pdf);
            _th.Job.Profile.AutoSave.Enabled = true;

            _settings = new PdfCreatorSettings(null);
            _settings.ConversionProfiles.Add(_th.Job.Profile);
            _settings.ConversionProfiles[0].AutoSave.EnsureUniqueFilenames = true;
            _settings.ConversionProfiles[0].AutoSave.TargetDirectory       = _th.TmpTestFolder;
            _settings.ConversionProfiles[0].FileNameTemplate = "AutoSaveTestOutput";
            _settings.ConversionProfiles[0].OutputFormat     = OutputFormat.Pdf;

            //create empty file with original output filename
            var existingFile = Path.Combine(_th.TmpTestFolder, "AutoSaveTestOutput.pdf");

            CreateFile(existingFile);

            var expectedOutputFileWithAppendix = Path.Combine(_th.TmpTestFolder, "AutoSaveTestOutput_2.pdf");

            var autoSaveWorkflow = new AutoSaveWorkflow(_th.Job, _settings);

            autoSaveWorkflow.RunWorkflow();

            Assert.IsTrue(File.Exists(existingFile), "Already existing file with outputfilename does not exist anymore.");
            var fileInfo = new FileInfo(existingFile);

            Assert.IsTrue(fileInfo.Length == 0, "Already existing (empty) file with outputfilename has been overwritten.");

            Assert.IsTrue(File.Exists(expectedOutputFileWithAppendix), "Expected outputfile (with appendix) does not exist.");
            fileInfo = new FileInfo(expectedOutputFileWithAppendix);
            Assert.IsFalse(fileInfo.Length == 0, "Expected outputfile (with appendix) is empty.");
        }
Exemple #3
0
        public void TestAutoSave_MultipleOutputFiles_EnsureUniqueFilenamesIsEnabled_OutputFilenamesDoNotExist()
        {
            _th.GenerateGsJob(PSfiles.ThreePDFCreatorTestpages, OutputFormat.Jpeg);
            _th.Job.Profile.AutoSave.Enabled = true;

            _settings = new PdfCreatorSettings(null);
            _settings.ConversionProfiles.Add(_th.Job.Profile);
            _settings.ConversionProfiles[0].AutoSave.EnsureUniqueFilenames = true;
            _settings.ConversionProfiles[0].AutoSave.TargetDirectory       = _th.TmpTestFolder;
            _settings.ConversionProfiles[0].FileNameTemplate = "AutoSaveTestOutput";
            _settings.ConversionProfiles[0].OutputFormat     = OutputFormat.Jpeg;

            var autoSaveWorkflow = new AutoSaveWorkflow(_th.Job, _settings);

            var expectedOutputFile1 = Path.Combine(_th.TmpTestFolder, "AutoSaveTestOutput1.jpg");
            var expectedOutputFile2 = Path.Combine(_th.TmpTestFolder, "AutoSaveTestOutput2.jpg");
            var expectedOutputFile3 = Path.Combine(_th.TmpTestFolder, "AutoSaveTestOutput3.jpg");

            autoSaveWorkflow.RunWorkflow();

            Assert.IsTrue(File.Exists(expectedOutputFile1), "Expected first outputfile does not exist.");
            Assert.IsTrue(File.Exists(expectedOutputFile2), "Expected second outputfile does not exist.");
            Assert.IsTrue(File.Exists(expectedOutputFile3), "Expected third outputfile does not exist.");

            var fileInfo = new FileInfo(expectedOutputFile1);

            Assert.IsFalse(fileInfo.Length == 0, "Expected first outputfile is empty.");

            fileInfo = new FileInfo(expectedOutputFile2);
            Assert.IsFalse(fileInfo.Length == 0, "Expected second outputfile is empty.");

            fileInfo = new FileInfo(expectedOutputFile3);
            Assert.IsFalse(fileInfo.Length == 0, "Expected third outputfile is empty.");
        }
Exemple #4
0
        public void SetUp()
        {
            _jobInfo          = new JobInfo();
            _jobInfo.Metadata = new Metadata();
            _job            = new Job(_jobInfo, _profile, new JobTranslations(), new Accounts());
            _profileChecker = Substitute.For <IProfileChecker>();
            _profileChecker.ProfileCheck(Arg.Any <ConversionProfile>(), Arg.Any <Accounts>()).Returns(_validActionResult);

            _query          = Substitute.For <ITargetFileNameComposer>();
            _jobRunner      = Substitute.For <IJobRunner>();
            _jobDataUpdater = Substitute.For <IJobDataUpdater>();

            _workflow = new AutoSaveWorkflow(_jobDataUpdater, _jobRunner, _profileChecker, _query, null);
        }
Exemple #5
0
        public void AuthorTemplateTest()
        {
            _th.GenerateGsJob(PSfiles.PDFCreatorTestpage, OutputFormat.Pdf);
            _th.JobInfo.Metadata.PrintJobAuthor = "Author from Job";

            _th.Job.Profile.AutoSave.Enabled = true;

            _settings = new PdfCreatorSettings(null);
            _settings.ConversionProfiles.Add(_th.Job.Profile);
            _settings.ConversionProfiles[0].AutoSave.EnsureUniqueFilenames = false;
            _settings.ConversionProfiles[0].AutoSave.TargetDirectory       = _th.TmpTestFolder;
            _settings.ConversionProfiles[0].FileNameTemplate = "AutoSaveTestOutput";
            _settings.ConversionProfiles[0].OutputFormat     = OutputFormat.Pdf;
            _settings.ConversionProfiles[0].AuthorTemplate   = "<PrintJobAuthor> + some text";

            var autoSaveWorkflow = new AutoSaveWorkflow(_th.Job, _settings);

            autoSaveWorkflow.RunWorkflow();

            var pdf = new PdfReader(_th.Job.OutputFiles[0]);

            Assert.AreEqual("Author from Job + some text", pdf.Info["Author"], "Wrong author in PDF Metadata");
        }