This is my scenario, I want to make a Data-Driven unit test, and for being environment-independent i want to embed the data file in my assembly. How can i reference then in the DataSourceAttribute of the Unit Test?.
I'm trying to access an Excel 2003 file using the Microsoft Jet OleDB Provider. The unit test works fine when the file is in the Hard-Drive but not when i try to access the embedded assembly file. Here is my example:
Original
[DeploymentItem("IHRM.Infrastructure.EFRepositories.Tests\DataDriven.xls"), DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\DataDriven.xls;Extended Properties=\"Excel 8.0\"", "Sheet1$", DataAccessMethod.Sequential), TestMethod]
Suggested
[DataSource("System.Data.OleDb", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="what to put here";Extended Properties=\"Excel 8.0\"", "Sheet1$", DataAccessMethod.Sequential), DeploymentItem("IHRM.Infrastructure.EFRepositories.Tests\DataDriven.xls"), TestMethod]