Effort Unit test: Argument 'xmlReader' is not valid


Question

I'm currently trying to unit test a context class of the Entity Framework with the "Effort" framework (http://effort.codeplex.com/wikipage?title=Tutorials&referringTitle=Home)

If my unit test project has two classes that contain methods use effort then i get the following error:

Argument 'xmlReader' is not valid. A minimum of one .ssdl artifact must be supplied.

It appears to be that having the than one method using effort across more than one class causes the error. I rather not have all my unit test functions in one class.

Code the test is running:

IDataLoader loader = new Effort.DataLoaders.CsvDataLoader(Path.Combine(TestContext.DeploymentDirectory, "csvFiles"));
using (EntityConnection connection = Effort.EntityConnectionFactory.CreateTransient("name=Entities", loader))
{
    BussinnesLayer.Customer[] customers = Customer.GetCustomers(connection);
    Assert.IsTrue(customers.Length > 0, "Customer list length = 0");
}

App.Config contains the following for the entity connection string: (removed sensitive data)

<add name="Entities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=servername;initial catalog=database;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Any help would be appreciated.

Accepted Answer

I ran into the same 'xmlReader' is not valid error.

The problem turned out to be locating the ssdl artifact. It worked in tests that later referenced my Entity Framework objects, but just creating a connection by itself would fail.

This helped me.

Try modifying your App.Config line to include the assembly name instead of the *. So if your assembly is named Project1.EF your App.Config line would look something like:

<add name="Entities" connectionString="metadata=res://Project1.EF/Model.csdl|res://Project1.EF/Model.ssdl|res://Project1.EF/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=servername;initial catalog=database;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />




Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why