Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何使用文件LocalTestRun.testrunconfig配置测试部署?_Asp.net_Sql Server_Database_Nhibernate - Fatal编程技术网

Asp.net 如何使用文件LocalTestRun.testrunconfig配置测试部署?

Asp.net 如何使用文件LocalTestRun.testrunconfig配置测试部署?,asp.net,sql-server,database,nhibernate,Asp.net,Sql Server,Database,Nhibernate,首先,如果问题不是很清楚,我很抱歉。 在第一章中,当我运行一个测试项目时,我正在学习nHibernate,我收到以下错误:测试方法TestProject1.NHibernatedataProviderTest.CanGetCustomerBydTest引发异常:NHibernate.HibernateeException:解析配置问题:System.IO.DirectoryNotFoundException:找不到路径的一部分'C:\Program Files\Microsoft Visual

首先,如果问题不是很清楚,我很抱歉。 在第一章中,当我运行一个测试项目时,我正在学习nHibernate,我收到以下错误:测试方法TestProject1.NHibernatedataProviderTest.CanGetCustomerBydTest引发异常:NHibernate.HibernateeException:解析配置问题:System.IO.DirectoryNotFoundException:找不到路径的一部分'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblys;PrivateSassemblies\hibernate.cfg.xml'

我用谷歌搜索了这个问题,搜索结果显示VS 2008路径错误(错误),将hibernate.cfg.xml放在测试项目中,并添加了属性:[TestMethod(),DeploymentItem(“hibernate.cfg.xml”)] 做完这件事后,我仍然遇到同样的问题

但是,当我使用Visual Studio 2010时,出现以下错误: 测试方法TestProject1.NHibernateDataProviderTestTest.CanGetCustomerBydTest引发异常:
System.NullReferenceException:对象引用未设置为对象的实例

看起来有两个不同的问题

首先在项目中放置nhibernate.cfg.xml,并在testsetup中的某个地方给出新配置的路径(“hibernate.cfg.xml的路径”)

第二个看起来像getmethod返回null,因为它无法在数据库中找到具有给定id的客户。如果在内存中使用SQLite,典型的验证码是,每个新连接指向不同的数据库->使用
sf.OpenSession(theOneConnection)
Session.Clear()
打开会话,而不是创建新的连接

希望它基本上有帮助(取决于您的问题:如何使用文件LocalTestRun.testrunconfig配置测试部署?

以下是您可以遵循的方法:

在运行配置中选择要部署的文件或文件夹

在解决方案资源管理器中的“解决方案项”下,双击要编辑的运行配置文件

此时会出现一个名为.testrunconfig的对话框。 单击部署

在“要部署的其他文件或目录”下,指定要复制的其他文件或文件夹

为此,, 单击〖增加档案〗按钮,选择档案;这将打开“添加部署文件”对话框

也可以单击“添加目录”以使用“添加部署目录”对话框选择文件夹

在.testrunconfig对话框中,单击保存,然后单击确定

每当此运行配置文件处于活动状态时,这些部署项将复制到部署文件夹

希望这会有所帮助