private static void TestFile( List <PollerTestResult> retValue, ITikaAnalyzer analyzer, String fileName, String type, String expected, Byte[] fileContent) { var tempFile = Path.Combine(Path.GetTempPath(), fileName); if (File.Exists(tempFile)) { File.Delete(tempFile); } File.WriteAllBytes(tempFile, fileContent); try { string content = analyzer.GetHtmlContent(tempFile, ""); if (content.Contains(expected)) { retValue.Add(new PollerTestResult(true, type + " conversion")); } else { retValue.Add(new PollerTestResult(false, type + " conversion: wrong content")); } } catch (Exception ex) { retValue.Add(new PollerTestResult(false, type + " conversion: " + ex.Message)); } }
private static void TestFile( List<PollerTestResult> retValue, ITikaAnalyzer analyzer, String fileName, String type, String expected, Byte[] fileContent) { var tempFile = Path.Combine(Path.GetTempPath(), fileName); if (File.Exists(tempFile)) File.Delete(tempFile); File.WriteAllBytes(tempFile, fileContent); try { string content = analyzer.GetHtmlContent(tempFile, ""); if (content.Contains(expected)) { retValue.Add(new PollerTestResult(true, type + " conversion")); } else { retValue.Add(new PollerTestResult(false, type + " conversion: wrong content")); } } catch (Exception ex) { retValue.Add(new PollerTestResult(false, type + " conversion: " + ex.Message)); } }
public List <PollerTestResult> Execute() { List <PollerTestResult> retValue = new List <PollerTestResult>(); ITikaAnalyzer analyzer = BuildAnalyzer(); TestFile(retValue, analyzer, "tika_test_doc.docx", "docx", "Lorem Ipsum", TestFiles.docx); TestFile(retValue, analyzer, "tika_test_ppt.pptx", "pptx", "PPT TITLE", TestFiles.pptx); return(retValue); }