forked from nissl-lab/toxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExcelTextParserTest.cs
68 lines (66 loc) · 2.74 KB
/
ExcelTextParserTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Toxy.Test
{
[TestFixture]
public class ExcelTextParserTest
{
[Test]
public void TestExcel2003TextParser()
{
ParserContext context = new ParserContext(TestDataSample.GetExcelPath("Employee.xls"));
ITextParser parser = ParserFactory.CreateText(context);
string result= parser.Parse();
Assert.IsNotNull(result);
Assert.IsTrue(result.IndexOf("Last name")>0);
Assert.IsTrue(result.IndexOf("First name") > 0);
}
[Test]
public void TestExcel2007TextParser()
{
ParserContext context = new ParserContext(TestDataSample.GetExcelPath("WithVariousData.xlsx"));
ITextParser parser = ParserFactory.CreateText(context);
string result = parser.Parse();
Assert.IsNotNull(result);
Assert.IsTrue(result.IndexOf("Foo") > 0);
Assert.IsTrue(result.IndexOf("Bar") > 0);
Assert.IsTrue(result.IndexOf("a really long cell") > 0);
Assert.IsTrue(result.IndexOf("have a header") > 0);
Assert.IsTrue(result.IndexOf("have a footer") > 0);
Assert.IsTrue(result.IndexOf("This is the header") < 0);
}
[Test]
public void TestExcel2007TextParserWithoutComment()
{
ParserContext context = new ParserContext(TestDataSample.GetExcelPath("WithVariousData.xlsx"));
context.Properties.Add("IncludeComments","0");
ITextParser parser = ParserFactory.CreateText(context);
string result = parser.Parse();
Assert.IsNotNull(result);
Assert.IsTrue(result.IndexOf("Comment by") < 0);
}
[Test]
public void TestExcel2007TextParserWithoutSheetNames()
{
ParserContext context = new ParserContext(TestDataSample.GetExcelPath("WithVariousData.xlsx"));
context.Properties.Add("IncludeSheetNames", "0");
ITextParser parser = ParserFactory.CreateText(context);
string result = parser.Parse();
Assert.IsNotNull(result);
Assert.IsTrue(result.IndexOf("Sheet1") < 0);
}
[Test]
public void TestExcel2007TextParserWithHeaderFooter()
{
ParserContext context = new ParserContext(TestDataSample.GetExcelPath("WithVariousData.xlsx"));
context.Properties.Add("IncludeHeaderFooter", "1");
ITextParser parser = ParserFactory.CreateText(context);
string result = parser.Parse();
Assert.IsNotNull(result);
Assert.IsTrue(result.IndexOf("This is the header") > 0);
}
}
}