public void TestParseDirectoryFromZip() { ParserContext context = new ParserContext(TestDataSample.GetFilePath("toxy.zip", null)); ITextParser parser = ParserFactory.CreateText(context); string list = parser.Parse(); Assert.IsNotNull(list); string[] lines = list.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual(68, lines.Length); }
public void ReadEmlTest() { string path = TestDataSample.GetFilePath("test.eml", null); ParserContext context = new ParserContext(path); IEmailParser parser = ParserFactory.CreateEmail(context); ToxyEmail email = parser.Parse(); Assert.AreEqual(1, email.From.Count); Assert.AreEqual(1, email.To.Count); Assert.AreEqual("=?utf-8?B?5ouJ5Yu+572R?= <*****@*****.**>", email.From[0]); Assert.AreEqual("*****@*****.**", email.To[0]); Assert.IsTrue(email.Subject.StartsWith("=?utf-8?B?5LiK5rW35YiG5LyX5b635bOw5bm/5ZGK?= =?utf-8?B?5Lyg5p")); Assert.IsTrue(email.Body.StartsWith("------=_Part_4546_1557510524.1418357602217\r\nContent-Type: text")); Assert.IsNull(email.HtmlBody); }
public void TestParseIndexOutOfRange() { string path = TestDataSample.GetFilePath("countrylist.csv", null); ParserContext context = new ParserContext(path); context.Properties.Add("HasHeader", "1"); ISpreadsheetParser parser = (ISpreadsheetParser)ParserFactory.CreateSpreadsheet(context); try { ToxyTable ss = parser.Parse(1); } catch (ArgumentOutOfRangeException ex) { Assert.IsTrue(ex.Message.Contains("CSV only has one table")); } }
public void TestParseToxySpreadsheet() { string path = TestDataSample.GetFilePath("countrylist.csv", null); ParserContext context = new ParserContext(path); context.Properties.Add("HasHeader", "1"); ISpreadsheetParser parser = (ISpreadsheetParser)ParserFactory.CreateSpreadsheet(context); ToxySpreadsheet ss = parser.Parse(); Assert.AreEqual(1, ss.Tables.Count); Assert.AreEqual(14, ss.Tables[0].ColumnHeaders.Cells.Count); Assert.AreEqual("Sort Order", ss.Tables[0].ColumnHeaders.Cells[0].Value); Assert.AreEqual("Sub Type", ss.Tables[0].ColumnHeaders.Cells[4].Value); Assert.AreEqual(272, ss.Tables[0].Rows.Count); Assert.AreEqual(12, ss.Tables[0].Rows[12].RowIndex); Assert.AreEqual("Kingdom of Bahrain", ss.Tables[0].Rows[12].Cells[2].ToString()); Assert.AreEqual(".bo", ss.Tables[0].Rows[20].Cells[13].ToString()); Assert.AreEqual(271, ss.Tables[0].LastRowIndex); }