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 }
/// <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)); }
public void TransfrormToInfFile_WithoutPrinter_PrinterNameInPsFileIsPDFCreator() { var infFile = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder); var content = File.ReadAllLines(infFile); Assert.Contains("PrinterName=PDFCreator", content); }
public void TransfrormToInfFile_InfFileContainsFileWithDirectoryAsDocumentTitle() { var infFile = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder); var content = File.ReadAllLines(infFile); Assert.Contains("DocumentTitle=" + _psTestFile, content); }
public void TransfrormToInfFile_InfFileContainsSourceFileTypePs() { var infFile = PsFileHelper.TransformToInfFile(_psTestFile, _testSpoolfolder); var content = File.ReadAllLines(infFile); Assert.Contains("SourceFileType=ps", content); }
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"); }
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); }
/// <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); } }
public void TransfrormToInfFile_PsFileIsEmpty_ReturnsEmptyString() { Assert.IsEmpty(PsFileHelper.TransformToInfFile("", "something")); }