public void Convert_When_PowerPointFileNotFound_Then_NullIsRetuned() { PowerPointToPdfConverter converter = new PowerPointToPdfConverter(); string newFilePath = converter.Convert("test.pptx", "Temp"); Assert.That(newFilePath, Is.Null); }
public static IConverter GetConverter(SupportedExtensions extension) { IConverter converter = null; switch (extension) { case SupportedExtensions.doc: case SupportedExtensions.docx: converter = new WordToPdfConverter(); break; case SupportedExtensions.ppt: case SupportedExtensions.pptx: converter = new PowerPointToPdfConverter(); break; case SupportedExtensions.xls: case SupportedExtensions.xlsx: converter = new ExcelToHtmlConverter(); break; case SupportedExtensions.rtf: converter = new RtfToPdfConverter(); break; case SupportedExtensions.eml: case SupportedExtensions.msg: converter = new MailToHtmlConverter(); break; } return(converter); }
public void Convert_When_PowerPointIsProtected_Then_FileCanBeConverted() { PowerPointToPdfConverter converter = new PowerPointToPdfConverter(); string root = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.CurrentContext.TestDirectory)); string newFilePath = converter.Convert(Path.Combine(root, "Samples\\sample-protected.pptx"), Path.Combine(root, "Temp")); Assert.That(newFilePath, Is.Not.Null); Assert.That(Path.GetExtension(newFilePath), Is.EqualTo(".pdf")); }
public void Convert_When_PowerPointDestinationPathDoesNotExist_Then_DirectoryIsCreated() { string currentDateSpan = DateTime.Now.Ticks.ToString(); PowerPointToPdfConverter converter = new PowerPointToPdfConverter(); string root = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.CurrentContext.TestDirectory)); Assert.That(Directory.Exists(Path.Combine(root, "Temp" + currentDateSpan)), Is.False); converter.Convert(Path.Combine(root, "Samples\\sample.pptx"), Path.Combine(root, "Temp" + currentDateSpan)); Assert.That(Directory.Exists(Path.Combine(root, "Temp" + currentDateSpan)), Is.True); Directory.Delete(Path.Combine(root, "Temp" + currentDateSpan), true); }