0

When trying to connect to a database using NUnit in VisualStudio17 or Jetbrains Rider, I am consistently getting a 30+ second delay in the connection before it runs. However, when I open a connection in LINQPad or run a command line app that establishes a connection, it is instantaneous. I have also tried invoking an NUnit test which establishes a connection from LINQPad, and the result is also instantaneous. Other members of my team with the same environment do not have this issue.

Our theory is that VisualStudio and Rider are running into some timeout issue (possibly due to IntegratedSecurity) before successfully connecting, but we can't figure out why this would be any different from the connections created using other means. Any ideas for what to try next or what could be going on here?

using System.Data.SqlClient;
using NUnit.Framework;

namespace ConnectionTest
{
    public class ConnectionTestClass
    {
        [Test]
        public void TestMethod()
        {
            var connectionStringBuilder = new SqlConnectionStringBuilder
            {
                DataSource = "server_name",
                InitialCatalog = "database_name",
                IntegratedSecurity = true
            };

            var connection = new SqlConnection(connectionStringBuilder.ConnectionString);
            connection.Open();
            connection.Close();
        }
    }
}
  • With VS2017, are you talking about runtime during debugging or connecting to the db through server explorer? – squillman Nov 02 '18 at 14:15
  • I was referencing runtime during test execution (with and without debugging). I am not using server explorer. However, I just tested the connection using server explorer and it also seemed slow, but I have never used server explorer before and don't have a reference. The main concern from me is the unit tests running slowly. – Justin Malin Nov 02 '18 at 15:20

0 Answers0