2010-11-18 85 views
1

我有一个MVC项目,我有一个类库设置作为我的测试项目。然而,使用NUnit运行我的测试时,抱怨没有找到Nhibernate.config(这是在我的Web项目斌Nunit抱怨Nhibernate.config文件丢失?

确切的错误:

<solutionName>.UnitTests.CatelogEditing.Can_View_All_Products_On_Admin_Product_List: 
System.TypeInitializationException : The type initializer for '<solutionName>.Domain.Infrastructure.BootStrapper' threw an exception. 
    ----> NHibernate.Cfg.HibernateConfigException : An exception occurred during configuration of persistence layer. 
    ----> System.IO.FileNotFoundException : Could not find file '<myrootpath>.UnitTests\bin\Debug\nhibernate.config'. 

任何帮助是极大的赞赏。

回答

2

您需要的配置文件添加到您的测试项目,因为它不知道你的web项目,并没有看到NH配置文件

+0

我已经复制了它,但没有意识到属性会默认回来。所以构建操作和复制设置不到位。 – pghtech 2010-11-18 17:15:19

+0

任何想法,一旦我得到了这个错误,单位想抱怨,它找不到“命名连接字符串”,并列出我的电脑名称。我正在使用“cfg.SetProperty(NHibernate.Cfg.Environment.ConnectionStringName,System.Environment.MachineName);”在我的CreateSessionFactory方法中,并添加了属性“name = ”到我的Web.config中。 – pghtech 2010-11-18 18:07:21

4

有您设置的配置文件的以下属性:

生成操作:内容

复制到输出目录:复制始终

为了确保它复制到bin目录?