Skip to content

Commit

Permalink
change MSUnit to NUnit to enable unittest on mono
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyqus committed Dec 31, 2014
1 parent c9a26bf commit 7863bf9
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 64 deletions.
Binary file added 3rdParty/nunit.framework.dll
Binary file not shown.
6 changes: 3 additions & 3 deletions Toxy.Test/CsvParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Toxy.Test
{
[TestClass]
[TestFixture]
public class CsvParserTest
{
[TestMethod]
[Test]
public void TestParseToxySpreadsheet()
{
string path = TestDataSample.GetFilePath("countrylist.csv", null);
Expand Down
8 changes: 4 additions & 4 deletions Toxy.Test/DateTimeParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Toxy.Test
{
[TestClass]
[TestFixture]
public class DateTimeParserTest
{
[TestMethod]
[Test]
public void TestParseDatetimeWithTimezone()
{
Assert.AreEqual(new DateTime(2008, 10, 25, 3, 9, 6), DateTimeParser.Parse("24-oct-08 21:09:06 CEST"));
Expand All @@ -18,7 +18,7 @@ public void TestParseDatetimeWithTimezone()

}

[TestMethod]
[Test]
public void TestParseDatetimeWithoutTimezone()
{
Assert.AreEqual(new DateTime(2014, 12, 12, 12, 13, 30), DateTimeParser.Parse("Fri, 12 Dec 2014 12:13:30"));
Expand Down
16 changes: 8 additions & 8 deletions Toxy.Test/Excel2003ParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;

namespace Toxy.Test
{
/// <summary>
/// Summary description for ExcelParserTest
/// </summary>
[TestClass]
[TestFixture]
public class Excel2003ParserTest:ExcelParserBaseTest
{
public Excel2003ParserTest()
Expand All @@ -18,34 +18,34 @@ public Excel2003ParserTest()
// TODO: Add constructor logic here
//
}
[TestMethod]
[Test]
public void TestExtractFooter()
{
BaseTestFooter("45538_classic_Footer.xls");
}
[TestMethod]
[Test]
public void TestExtractHeader()
{
BaseTestHeader("45538_classic_Header.xls");
}
[TestMethod]
[Test]
public void TestFillBlankCells()
{
base.BaseTestFillBlankCells("Employee.xls");
}

[TestMethod]
[Test]
public void TestExcelWithFormats()
{
BaseTestExcelFormatedString("Formatting.xls");
}

[TestMethod]
[Test]
public void TestExcelParserSimple()
{
base.BaseTestExcelContent("Employee.xls");
}
[TestMethod]
[Test]
public void TestExcelWithComments()
{
base.BaseTestExcelComment("comments.xls");
Expand Down
14 changes: 7 additions & 7 deletions Toxy.Test/Excel2007ParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;

namespace Toxy.Test
{
/// <summary>
/// Summary description for ExcelParserTest
/// </summary>
[TestClass]
[TestFixture]
public class Excel2007ParserTest:ExcelParserBaseTest
{
public Excel2007ParserTest()
Expand All @@ -19,28 +19,28 @@ public Excel2007ParserTest()
//
}

[TestMethod]
[Test]
public void TestExtractFooter()
{
BaseTestFooter("45540_classic_Footer.xlsx");
}
[TestMethod]
[Test]
public void TestExtractHeader()
{
BaseTestHeader("45540_classic_Header.xlsx");
}
[TestMethod]
[Test]
public void TestExtractWithoutHeader()
{
BaseTestWithoutHeader("WithVariousData.xlsx");
}
[TestMethod]
[Test]
public void TestExcelWithFormats()
{
BaseTestExcelFormatedString("Formatting.xlsx");
}

[TestMethod]
[Test]
public void TestExcelWithComments()
{
base.BaseTestExcelComment("comments.xlsx");
Expand Down
2 changes: 1 addition & 1 deletion Toxy.Test/ExcelParserBaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
68 changes: 68 additions & 0 deletions Toxy.Test/ExcelTextParserTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
}
}
}
6 changes: 3 additions & 3 deletions Toxy.Test/HtmlParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System.Collections.Generic;
using System.IO;

namespace Toxy.Test
{
[TestClass]
[TestFixture]
public class HtmlParserTest
{
[TestMethod]
[Test]
public void TestParseHtml()
{
string path = Path.GetFullPath(TestDataSample.GetHtmlPath("mshome.html"));
Expand Down
8 changes: 4 additions & 4 deletions Toxy.Test/PDFParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -7,10 +7,10 @@

namespace Toxy.Test
{
[TestClass]
[TestFixture]
public class PDFParserTest
{
[TestMethod]
[Test]
public void TestParsePlainTextFromPDF()
{
string path = TestDataSample.GetPdfPath("Sample1.PDF");
Expand All @@ -19,7 +19,7 @@ public void TestParsePlainTextFromPDF()
Assert.IsTrue(result.StartsWith("LA MARCHE"));
}

[TestMethod]
[Test]
public void TestParseToxyDocumentFromPDF()
{
string path = TestDataSample.GetPdfPath("Sample1.PDF");
Expand Down
8 changes: 4 additions & 4 deletions Toxy.Test/PlainTextParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Toxy.Parsers;

namespace Toxy.Test
{
[TestClass]
[TestFixture]
public class PlainTextParserTest
{
[TestMethod]
[Test]
public void TestReadWholeText()
{
string path = TestDataSample.GetTextPath("utf8.txt");
Expand All @@ -18,7 +18,7 @@ public void TestReadWholeText()
Assert.AreEqual("hello world\r\na2\r\na3\r\nbbb4\r\n", text);
}

[TestMethod]
[Test]
public void TestParseLineEvent()
{
string path = TestDataSample.GetTextPath("utf8.txt");
Expand Down
6 changes: 3 additions & 3 deletions Toxy.Test/RTFParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -7,10 +7,10 @@

namespace Toxy.Test
{
[TestClass]
[TestFixture]
public class RTFParserTest
{
[TestMethod]
[Test]
public void TestReadRTF()
{
string path = TestDataSample.GetRTFPath("Formated text.rtf");
Expand Down
17 changes: 16 additions & 1 deletion Toxy.Test/TestDataSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ public static string GetHtmlPath(string filename)
{
return GetFilePath(filename, "Html");
}

public static string GetAudioPath(string filename)
{
return GetFilePath(filename, "Audio");
}
public static string GetImagePath(string filename)
{
return GetFilePath(filename, "Image");
}
public static string GetOLE2Path(string filename)
{
return GetFilePath(filename, "OLE2");
}
public static string GetOOXMLPath(string filename)
{
return GetFilePath(filename, "OOXML");
}
public static string GetFilePath(string filename, string subFolder)
{
string path = ConfigurationManager.AppSettings["testdataPath"];
Expand Down
10 changes: 5 additions & 5 deletions Toxy.Test/TestToxySpreadsheet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Data;
Expand All @@ -7,10 +7,10 @@

namespace Toxy.Test
{
[TestClass]
[TestFixture]
public class TestToxySpreadsheet
{
[TestMethod]
[Test]
public void TestReadExcelAndConvertToDataSet()
{
ParserContext c=new ParserContext(TestDataSample.GetExcelPath("employee.xls"));
Expand All @@ -34,7 +34,7 @@ public void TestReadExcelAndConvertToDataSet()
Assert.AreEqual("SSN:", s1.Rows[5][1]);
Assert.AreEqual("ssn", s1.Rows[5][2]);
}
[TestMethod]
[Test]
public void TestToxyTableToDataTable()
{
#region create ToxyTable
Expand Down Expand Up @@ -87,7 +87,7 @@ public void TestToxyTableToDataTable()
Assert.AreEqual("9", dt.Rows[2][3].ToString());
}

[TestMethod]
[Test]
public void TestToxyTableToDataTable_withEmptyColumnHeader()
{
#region create ToxyTable
Expand Down
Loading

0 comments on commit 7863bf9

Please sign in to comment.