繁体   English   中英

在使用EFProf(Entity Framework Profiler)进行单元测试中使用Effort的ASP Boilerplate问题

[英]ASP Boilerplate problems using Effort in unit testing with EFProf (Entity Framework Profiler)

使用EFProf( http://www.hibernatingrhinos.com/products/EFProf )和ASP Boilerplate( http://www.aspnetboilerplate.com/ )时遇到问题。

对于单元测试,ASP Boilerplate使用Effort( https://github.com/tamasflamich/effort )在内存中模拟数据库。

如果我运行单元测试时未添加对EFProf的引用,则测试将正确运行(绿色)。

如果添加初始化行:

HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.Initialize();

在我的测试库ctor或应用程序项目的Initialize()中,出现以下错误:

Castle.MicroKernel.ComponentActivator.ComponentActivatorException

ComponentActivator:无法实例化MyApp.EntityFramework.MyAppDataContext

内部异常具有相关信息:

Error: Unable to cast object of type 'Effort.Provider.EffortConnection' to type 'HibernatingRhinos.Profiler.Appender.ProfiledDataAccess.ProfiledConnection'.

努力仅仅是与EFProf不兼容吗? 还是我在初始化过程中做了一些明显错误的事情?

回答我自己的问题:努力会伪造DbContect对象,但实际上并没有为内存创建SQL,因此没有探查器可以拦截的内容。 这也是为什么使用EF6的Database.Log时,CommandText始终为null的原因。

我打算尝试将Moq与EF6结合使用,以使用内存数据库实现进行测试,以替代Asp Boilerplate的利用本文努力的测试项目: https ://msdn.microsoft.com/zh-cn/library/dn314429 (v = vs.113).aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM