I have about 1600 test which passes and i've added one test with DeploymentItem and DataSource to get testcases from prepared XML. Test alone works, it even work in whole testclass but when I try to run all test all tests fails. We use EF and VS Test.
In every test there's the same error:
OTController_Test.TestInitialize Returned exception. System.InvalidOperationException: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information..
Test looks like this:
[DeploymentItem("C:\\Users\\mateusz.sobczyk\\Source\\Repos\\Aplixcom_InsertData\\Aplixcom_InsertData_Test\\XMLGenerator\\Tests\\test.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\test.xml", "XMLWrappedModel", DataAccessMethod.Sequential)]
[TestMethod]
public void testme()
{
string tmp = TestContext.DataRow["JsonModel"].ToString();
string failinfo = TestContext.DataRow["FailInfo"].ToString();
string TestCategory = TestContext.DataRow["TestCategory"].ToString();
Group obj = System.Web.Helpers.Json.Decode<Group>(tmp);
if (obj == null)
{
AssertAll.Execute(
() => Assert.AreEqual(null, tmp),
() => Assert.AreEqual("[ID:[FailedCreateFailInfo][Nazwa:[FailedCreateFailInfo]", failinfo),
() => Assert.AreEqual("Testy Mocy", TestCategory)
);
}
else
{
switch (obj.ID)
{
case 2:
AssertAll.Execute(
() => Assert.AreEqual("a", obj.Nazwa),
() => Assert.AreEqual("[ID: 2][Nazwa: a]", failinfo),
() => Assert.AreEqual("Testy Mocy", TestCategory)
);
break;
case 3:
AssertAll.Execute(
() => Assert.AreEqual("b", obj.Nazwa),
() => Assert.AreEqual("[ID: 3][Nazwa: b]", failinfo),
() => Assert.AreEqual("Testy Mocy", TestCategory)
);
break;
case 4:
AssertAll.Execute(
() => Assert.AreEqual("b", obj.Nazwa),
() => Assert.AreEqual("[ID: 4][Nazwa: b]", failinfo),
() => Assert.AreEqual("Testy Mocy", TestCategory)
);
break;
}
}
}
My web.config
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, EntityFramework6.Npgsql" />
</providers>
</entityFramework>
I have no clue how to fix this. I tried to refresh my references but it didn't helped. How do i make it work? Because from now on I wanted to use datasource in testing and I hope you will help me:)