I need to test some classes with Nunit by importing data from excel data source in C#,I couldn't find any helpful resource to guide me ,Is there any solution? Consider this test in Nunit
[Test]
[TestCase(new[] { -4, -3, -3, -2, -1, 0, 1, 2, 2, 3, 4 },
new []{1, 0, 1, 0,1, 0, 1, 1, 0, 1, 0})]
public void YourTest(int[] given, int[] expected)
{
///some code
}
I would read data from excel, If I have one excel files I put the given Values in first column and expected values in second column:
column1(in Excel) column2(in Excel)
-4 1
-3 0
-3 1
-2 0
-1 1
0 0
1 1
2 1
2 0
3 1
4 0
The reason I want to test with excel because I need to apply some formula on column1 and my formula results appers on column2 and I don't like to copy from excel to my test class.
In MsTest we have :
[TestMethod]
[Owner("Name")]
[TestProperty("TestCategory", "Developer"),
DataSource("Microsoft.ACE.OLEDB.12.0",
"Data Source=C:/Sheets/DataSheet.xlsx;Extended Properties=Excel 12.0;",
"[Sheet1$]",
DataAccessMethod.Sequential)]
Do we have the same thing in Nunit ,Or we need to simulate ? How we can simpuate it ? In [Setup] section or in [TestMethod]