diff --git a/Snowflake.Data.Tests/App.config b/Snowflake.Data.Tests/App.config index 62a7928d6..3bfa38262 100755 --- a/Snowflake.Data.Tests/App.config +++ b/Snowflake.Data.Tests/App.config @@ -21,7 +21,7 @@ Copyright (c) 2012-2017 Snowflake Computing Inc. All rights reserved. - + @@ -31,7 +31,7 @@ Copyright (c) 2012-2017 Snowflake Computing Inc. All rights reserved. - + diff --git a/Snowflake.Data.Tests/IntegrationTests/PoolConfigRestorer.cs b/Snowflake.Data.Tests/IntegrationTests/PoolConfigRestorer.cs new file mode 100644 index 000000000..d1a822de1 --- /dev/null +++ b/Snowflake.Data.Tests/IntegrationTests/PoolConfigRestorer.cs @@ -0,0 +1,26 @@ +using Snowflake.Data.Client; + +namespace Snowflake.Data.Tests.IntegrationTests +{ + class PoolConfigRestorer { + private readonly bool _pooling; + private readonly long _timeout; + private readonly int _maxPoolSize; + + public PoolConfigRestorer() + { + _maxPoolSize = SnowflakeDbConnectionPool.GetMaxPoolSize(); + _timeout = SnowflakeDbConnectionPool.GetTimeout(); + _pooling = SnowflakeDbConnectionPool.GetPooling(); + } + + public void Reset() + { + SnowflakeDbConnectionPool.SetMaxPoolSize(_maxPoolSize); + SnowflakeDbConnectionPool.SetTimeout(_timeout); + SnowflakeDbConnectionPool.SetPooling(_pooling); + } + } + + +} \ No newline at end of file diff --git a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs index d4529a564..e8b4fe0b8 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs @@ -22,13 +22,25 @@ namespace Snowflake.Data.Tests.IntegrationTests class SFConnectionIT : SFBaseTest { private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); + private static readonly PoolConfigRestorer s_previousPoolConfig = new PoolConfigRestorer(); + [SetUp] + public void BeforeTest() + { + s_previousPoolConfig.Reset(); + SnowflakeDbConnectionPool.ClearAllPools(); + } + + [TearDown] + public void AfterTest() + { + s_previousPoolConfig.Reset(); + } [Test] public void TestBasicConnection() { using (IDbConnection conn = new SnowflakeDbConnection()) { - bool pooling = SnowflakeDbConnectionPool.GetPooling(); SnowflakeDbConnectionPool.SetPooling(false); conn.ConnectionString = ConnectionString; conn.Open(); @@ -47,7 +59,6 @@ public void TestBasicConnection() conn.Close(); Assert.AreEqual(ConnectionState.Closed, conn.State); - SnowflakeDbConnectionPool.SetPooling(pooling); } } @@ -1755,7 +1766,6 @@ public void TestAsyncLoginTimeout() [Test, NonParallelizable] public void TestAsyncDefaultLoginTimeout() { - SnowflakeDbConnectionPool.SetPooling(false); using (var conn = new MockSnowflakeDbConnection()) { // unlimited retry count to trigger the timeout diff --git a/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolT.cs b/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolT.cs index 005db6605..6f858d7cf 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFConnectionPoolT.cs @@ -15,37 +15,16 @@ namespace Snowflake.Data.Tests.IntegrationTests using Snowflake.Data.Tests.Mock; using System.Data.Common; using Moq; - - class PoolConfig { - private readonly bool _pooling; - private readonly long _timeout; - private readonly int _maxPoolSize; - public PoolConfig() - { - _maxPoolSize = SnowflakeDbConnectionPool.GetMaxPoolSize(); - _timeout = SnowflakeDbConnectionPool.GetTimeout(); - _pooling = SnowflakeDbConnectionPool.GetPooling(); - } - - public void Reset() - { - SnowflakeDbConnectionPool.SetMaxPoolSize(_maxPoolSize); - SnowflakeDbConnectionPool.SetTimeout(_timeout); - SnowflakeDbConnectionPool.SetPooling(_pooling); - } - } - [TestFixture, NonParallelizable] class SFConnectionPoolT : SFBaseTest { - private static SFLogger logger = SFLoggerFactory.GetLogger(); - private static readonly PoolConfig previousPoolConfig = new PoolConfig(); + private static readonly PoolConfigRestorer s_previousPoolConfig = new PoolConfigRestorer(); [SetUp] public void BeforeTest() { - previousPoolConfig.Reset(); + s_previousPoolConfig.Reset(); SnowflakeDbConnectionPool.SetPooling(true); SnowflakeDbConnectionPool.ClearAllPools(); } @@ -53,7 +32,7 @@ public void BeforeTest() [TearDown] public void AfterTest() { - previousPoolConfig.Reset(); + s_previousPoolConfig.Reset(); } [OneTimeTearDown] @@ -435,12 +414,12 @@ public void TestConnectionPoolTurnOff() class SFConnectionPoolITAsync : SFBaseTestAsync { private static SFLogger logger = SFLoggerFactory.GetLogger(); - private static readonly PoolConfig previousPoolConfig = new PoolConfig(); + private static readonly PoolConfigRestorer s_previousPoolConfigRestorer = new PoolConfigRestorer(); [SetUp] public void BeforeTest() { - previousPoolConfig.Reset(); + s_previousPoolConfigRestorer.Reset(); SnowflakeDbConnectionPool.SetPooling(true); SnowflakeDbConnectionPool.ClearAllPools(); } @@ -448,7 +427,7 @@ public void BeforeTest() [TearDown] public void AfterTest() { - previousPoolConfig.Reset(); + s_previousPoolConfigRestorer.Reset(); } [OneTimeTearDown]