Esempio n. 1
0
 public void TransfrormToInfFile_SpoolFolderContainsFolderWithPsFileName()
 {
     var infFile          = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder);
     var spoolDirectories = Directory.GetDirectories(_testSpoolfolder);
     var psFileName       = Path.GetFileName(_psTestFile);
     var psDir            = spoolDirectories.First(x => x.EndsWith(psFileName)); //Throws Exception if element does not exist
 }
Esempio n. 2
0
        /// <summary>
        ///     Inserts a .ps or .pdf file directly into the queue.
        /// </summary>
        /// <param name="path">The path to the .ps or .pdf file</param>
        public void AddFileToQueue(string path)
        {
            PathCheck(path);

            var fileExtension  = Path.GetExtension(path) ?? string.Empty;
            var queueInstance  = JobInfoQueue.Instance;
            var legalFileTypes = new List <string> {
                ".ps", ".pdf"
            };

            if (!legalFileTypes.Contains(fileExtension.ToLower()))
            {
                throw new COMException("Only .ps and .pdf files can be directly added to the queue.");
            }

            var spoolFolder = queueInstance.SpoolFolder;

            if (!queueInstance.SpoolFolderIsAccessible())
            {
                throw new COMException("Accessing the spool folder failed.");
            }

            var infFile = PsFileHelper.TransformToInfFile(path, spoolFolder);

            queueInstance.Add(new JobInfo(infFile));
        }
Esempio n. 3
0
        public void TransfrormToInfFile_WithoutPrinter_PrinterNameInPsFileIsPDFCreator()
        {
            var infFile = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder);

            var content = File.ReadAllLines(infFile);

            Assert.Contains("PrinterName=PDFCreator", content);
        }
Esempio n. 4
0
        public void TransfrormToInfFile_InfFileContainsFileWithDirectoryAsDocumentTitle()
        {
            var infFile = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder);

            var content = File.ReadAllLines(infFile);

            Assert.Contains("DocumentTitle=" + _psTestFile, content);
        }
Esempio n. 5
0
        public void TransfrormToInfFile_InfFileContainsSourceFileTypePs()
        {
            var infFile = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder);

            var content = File.ReadAllLines(infFile);

            Assert.Contains("SourceFileType=ps", content);
        }
Esempio n. 6
0
        public void TransfrormToInfFile_InfFileBasicCheck()
        {
            var infFile = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder);

            Assert.IsTrue(File.Exists(infFile), "Inf file does not exist");

            StringAssert.StartsWith(_testSpoolfolder, infFile, "Inf file not in spool folder.");
            StringAssert.EndsWith(Path.GetFileName(_psTestFile), Path.GetDirectoryName(infFile), "Inf file not in folder named after ps file");
            Assert.AreEqual(".inf", Path.GetExtension(infFile), "Inf file has wrong extension.");
            Assert.AreEqual(Path.GetFileName(_psTestFile), Path.GetFileNameWithoutExtension(infFile), "Inf file not named after ps file");
            Assert.IsNotEmpty(File.ReadAllText(infFile), "Inf file is empty");
        }
Esempio n. 7
0
        public void TransfrormToInfFile_InfFileContainsPsFileInSpoolFolder()
        {
            var psFilename          = Path.GetFileName(_psTestFile);
            var psFileInSpoolFolder = Path.Combine(_testSpoolfolder, psFilename);

            psFileInSpoolFolder = Path.Combine(psFileInSpoolFolder, psFilename);

            var infFile = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder);

            var content = File.ReadAllLines(infFile);

            Assert.Contains("SpoolFileName=" + psFileInSpoolFolder, content);
        }
Esempio n. 8
0
        /// <summary>
        /// Adds files that do not have to be printed to the current JobInfoQueue.
        /// </summary>
        /// <param name="droppedFiles"></param>
        public static void AddFilesToJobInfoQueue(IEnumerable <string> droppedFiles)
        {
            foreach (var file in droppedFiles)
            {
                if (IsPrintFile(file))
                {
                    continue;
                }

                var infFile = PsFileHelper.TransformToInfFile(file, JobInfoQueue.Instance.SpoolFolder, SettingsHelper.Settings.ApplicationSettings.PrimaryPrinter);
                JobInfoQueue.Instance.Add(infFile);
            }
        }
Esempio n. 9
0
 public void TransfrormToInfFile_PsFileIsEmpty_ReturnsEmptyString()
 {
     Assert.IsEmpty(PsFileHelper.TransformToInfFile("", "something"));
 }