4

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:

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

Michael Pakhantsov
  • 24,855
  • 6
  • 60
  • 59

2 Answers2

1

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.

Michael Pakhantsov
  • 24,855
  • 6
  • 60
  • 59
0

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

Azodious
  • 13,752
  • 1
  • 36
  • 71