I am trying to build Test class of data-driven unit tests in C#. I want to use 3 databases: one from SQL, one from Access and one from Excel. This is my app.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.visualstudio.testtools"
type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection,
Microsoft.VisualStudio.QualityTools.UnitTestFramework,
Version=10.0.0.0,
Culture=neutral"/>
</configSections>
<connectionStrings>
<add name="MyJetConn"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=H:\SQA\CoolMath\CoolMath\Database1.accdb;
Persist Security Info=False;"
providerName="System.Data.OleDb" />
<add name="MyExcelConn"
connectionString="Dsn=Excel Files;
dbq=H:\SQA\CoolMath\CoolMath\CoolMathExcelDataTable.xlsx;
defaultdir=.;
driverid=1046;
maxbuffersize=2048;
pagetimeout=5"
providerName="System.Data.Odbc" />
<add name="MSSQLConn"
connectionString="Data Source=H:\SQA\CoolMath\CoolMath\SQLExpress;
Initial Catalog=MSSQLDB;
Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="MyJetDataSource"
connectionString="MyJetConn"
dataTableName="CoolMathAcessDataTable"
dataAccessMethod="Sequential"/>
<add name="MyExcelDataSource"
connectionString="MyExcelConn"
dataTableName="Sheet1$"
dataAccessMethod="Sequential"/>
<add name="MSSQLDataSource"
connectionString="MSSQLConn"
dataTableName="dbo.CoolMathDataTable"
dataAccessMethod="Sequential"/>
</dataSources>
</microsoft.visualstudio.testtools>
</configuration>
When I try to run the tests, they all fail with the message:
"Data source cannot be found in the test configuration settings".
I can't see what am I doing wrong, perhaps it is the location of the databases? (they all in the same library as the code project and the XML file).
Above the Unit Tests I've place the following attributes:
[TestMethod()] [DeploymentItem("CoolMath\\CoolMathExcelDataTable.xlsx")]
[DataSource("MyExcelDataSource")]