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:
开发者_StackOverflow中文版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
Obviously problem that is in environment.
How to 'configure' nunit for using 'same' settings as console application
some details:
target framework: 4.0 target platform: x86 nunit 2.5.9 OS: Windows 7 x64
Problem cause parenthesis in folder name. (C:\Program Files (x86))
If I run nunit from folder c:\something(nunit)\ I got same error.
Replacing VS path to short 8.3 names does not help me. So had to install Oracle Client 11 and problem is gone.
Check if following helps: http://ora-12154.ora-code.com/
精彩评论