public void GetsPDFText(string filePathOrUrl) { _getPDFText = new GetPDFTextCommand(); _engine = new AutomationEngineInstance(null); string filepath = ""; string projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; if (filePathOrUrl.Equals("File Path")) { filepath = Path.Combine(projectDirectory, @"Resources\dummy.pdf"); } else { filepath = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"; } VariableMethods.CreateTestVariable(filepath, _engine, "filepath", typeof(string)); VariableMethods.CreateTestVariable(null, _engine, "outputText", typeof(string)); _getPDFText.v_FileSourceType = filePathOrUrl; _getPDFText.v_FilePath = "{filepath}"; _getPDFText.v_OutputUserVariableName = "{outputText}"; _getPDFText.RunCommand(_engine); Assert.Equal("Dummy PDF file", "{outputText}".ConvertUserVariableToString(_engine)); }
public void HandlesInvalidFilepath() { _getPDFText = new GetPDFTextCommand(); _engine = new AutomationEngineInstance(null); string filepath = ""; VariableMethods.CreateTestVariable(filepath, _engine, "filepath", typeof(string)); _getPDFText.v_FileSourceType = "File Path"; _getPDFText.v_FilePath = "{filepath}"; _getPDFText.v_OutputUserVariableName = "{outputText}"; Assert.Throws <FileNotFoundException>(() => _getPDFText.RunCommand(_engine)); }