[英]piece of code works in console application, but does not works inside nunit test
Simple console application open connection without any problems: 简单的控制台应用程序打开连接没有任
static void Main(string[] args)
{
string connectionString = String.Format(
@"Provider=OraOLEDB.Oracle;PLSQLRSet=1;Password={0};Persist Security Info=True;User ID={1};Data Source={2};OLEDB.NET=true;FetchSize=5000",
"pwd", "schema", "server");
using (IDbConnection con = new OleDbConnection(connectionString))
{
con.Open();
Console.WriteLine("Opened");
}
Console.ReadKey();
}
but if try do same in the nunit test method: 但如果尝试在nunit测试方法中做同样的事情:
public class UnitTest1
{
[Test]
public void TestMethod1()
{
string connectionString = String.Format(
@"Provider=OraOLEDB.Oracle;PLSQLRSet=1;Password={0};Persist Security Info=True;User ID={1};Data Source={2};OLEDB.NET=true;FetchSize=5000",
"pwd", "schema", "server");
using (IDbConnection con = new OleDbConnection(connectionString))
{
con.Open();
}
}
}
I have got exception: ORA-12154: TNS:could not resolve the connect identifier specified 我有例外:ORA-12154:TNS:无法解析指定的连接标识符
Obviously problem that is in environment. 显然是环境问题。
How to 'configure' nunit for using 'same' settings as console application 如何'配置'nunit使用'相同'设置作为控制台应用程序
some details: 一些细节:
target framework: 4.0 target platform: x86 nunit 2.5.9 OS: Windows 7 x64 目标框架:4.0目标平台:x86 nunit 2.5.9操作系统:Windows 7 x64
Problem cause parenthesis in folder name. 问题导致文件夹名称中的括号。 (C:\\Program Files (x86)) (C:\\ Program Files(x86))
If I run nunit from folder c:\\something(nunit)\\ I got same error. 如果我从文件夹c:\\ something(nunit)\\运行nunit我得到了同样的错误。
Replacing VS path to short 8.3 names does not help me. 将VS路径替换为8.3短名称对我没有帮助。 So had to install Oracle Client 11 and problem is gone. 因此不得不安装Oracle Client 11,问题就消失了。
检查以下是否有帮助: http : //ora-12154.ora-code.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.