Effort Unit test: Argument 'xmlReader' is not valid

狂风中的少年 提交于 2019-12-10 10:26:26

问题


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.


回答1:


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" />


来源:https://stackoverflow.com/questions/28940360/effort-unit-test-argument-xmlreader-is-not-valid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!