Part of the code works in a console application, but does not work inside nunit test

A simple console application open connection without 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 you try to do the same in the nunit method:

 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 an exception: ORA-12154: TNS: could not determine the specified connection identifier

Obviously, the problem is in the environment.

How to configure "nunit" to use the "same" settings, such as a console application

some components:

target structure: 4.0 target platform: x86 nunit 2.5.9 OS: Windows 7 x64

+4
source share
2 answers

The problem causes the brackets in the folder name. (C: \ Program Files (x86))

If I ran nunit from the folder c: \ something (nunit) \ I got the same error.

Replacing the VS path with 8.3 short names does not help me. Therefore, I had to install Oracle Client 11, and the problem disappeared.

+1
source

Check if the following supports: http://ora-12154.ora-code.com/

0
source

All Articles