CollectionAssert来自Entity Framework的数据

时间:2016-04-04 21:13:28

标签: c# entity-framework unit-testing nunit

出于某种原因,我无法将CollectionAssert与NUnit和Entity Framework一起使用。我有一份预期结果列表(在这种情况下是客户)和从EF返回的集合。

当我尝试检查结果匹配时,而不是从EF中获得我期望的类型而不是获得名为System.Data.Entity.DynamicProxies的内容。

这是我的单元测试:

var expectedSearchResult = new SearchResult()
{
    FoundCustomers = new List<Customer>() {
        new Customer
        {
            FirstName = "Test", LastName = "Test", City = "Test", Country = "test", Phone = "00000000000" }
        }
};
var result = searchService.GeneralSearch("Test");
// Here I am expecting exactly one customer in result.FoundCustomers
// but I get a DynamicProxy instead
CollectionAssert.AreEqual(expectedSearchResult.FoundCustomers, result.FoundCustomers);

NUnit是否与Entity Framework不兼容?我错过了什么?

0 个答案:

没有答案