Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.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
C# Can';t在单元测试中阻止NHibernate将日志写入控制台_C#_Unit Testing_Nhibernate - Fatal编程技术网

C# Can';t在单元测试中阻止NHibernate将日志写入控制台

C# Can';t在单元测试中阻止NHibernate将日志写入控制台,c#,unit-testing,nhibernate,C#,Unit Testing,Nhibernate,我有一些在本地数据库上与nhibernate一起工作的单元测试 我并不总是需要show\u sql输出,所以我主要想停用它。但是无论我如何设置属性,无论是在测试项目的App.config中 <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="dialect">NHibernate.Dial

我有一些在本地数据库上与nhibernate一起工作的单元测试

我并不总是需要
show\u sql
输出,所以我主要想停用它。但是无论我如何设置属性,无论是在测试项目的
App.config

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
        <property name="connection.connection_string_name">test</property>
        <property name="show_sql">false</property>
        <mapping assembly="MyLib"/>
    </session-factory>
</hibernate-configuration>
控制台输出总是显示SQL语句,使控制台混乱不堪


我错过了什么?我是否设置了错误的值?

结果是,还有一点可以控制输出;直接在方法上

SchemaExport export = new SchemaExport(_configuration);
export.Create(true, true);
Create
方法提供两个参数:

bool useStdOut, bool execute
第一个定义SQL是否写入标准输出,第二个控制SQL是否针对数据库执行

从复制/粘贴教程开始,我总是将两者都设置为true,这会重写我之前配置的任何内容

将第一个参数设置为
false
后,我不再获得不需要的输出

bool useStdOut, bool execute