diff --git a/DbProxies.sln b/DbProxies.sln index 4b09c59..9b30464 100644 --- a/DbProxies.sln +++ b/DbProxies.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.27004.2002 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DbProxy", "DbProxy\DbProxy.csproj", "{C3E60435-AF5B-4874-97FF-5F89ED57CD9F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlProxy.Test", "SqlProxy.Test\SqlProxy.Test.csproj", "{47DF7B2C-FF07-46E7-B664-6A0797BA32D5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlProxy.Test", "SqlProxy.Test\SqlProxy.Test.csproj", "{47DF7B2C-FF07-46E7-B664-6A0797BA32D5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlProxy.ConsoleTester", "SqlProxy.ConsoleTester\SqlProxy.ConsoleTester.csproj", "{965B0BFB-183F-474F-9FC2-C4545F92E95A}" EndProject @@ -13,10 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlProxy", "SqlProxy\SqlPro EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DbProxy.Test", "DbProxy.Test\DbProxy.Test.csproj", "{0FB9E109-2126-43E3-9F0D-16A410A4654C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OracleProxy", "OracleProxy\OracleProxy.csproj", "{4CAA199F-F588-4A5F-84AA-90E592A802CD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OracleProxy.Test", "OracleProxy.Test\OracleProxy.Test.csproj", "{00D0DBF2-2E8E-4EAD-A9A3-257906DB19E9}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,14 +39,6 @@ Global {0FB9E109-2126-43E3-9F0D-16A410A4654C}.Debug|Any CPU.Build.0 = Debug|Any CPU {0FB9E109-2126-43E3-9F0D-16A410A4654C}.Release|Any CPU.ActiveCfg = Release|Any CPU {0FB9E109-2126-43E3-9F0D-16A410A4654C}.Release|Any CPU.Build.0 = Release|Any CPU - {4CAA199F-F588-4A5F-84AA-90E592A802CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4CAA199F-F588-4A5F-84AA-90E592A802CD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4CAA199F-F588-4A5F-84AA-90E592A802CD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4CAA199F-F588-4A5F-84AA-90E592A802CD}.Release|Any CPU.Build.0 = Release|Any CPU - {00D0DBF2-2E8E-4EAD-A9A3-257906DB19E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {00D0DBF2-2E8E-4EAD-A9A3-257906DB19E9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {00D0DBF2-2E8E-4EAD-A9A3-257906DB19E9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {00D0DBF2-2E8E-4EAD-A9A3-257906DB19E9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OracleProxy.Test/OracleConnectionProxyTests/FallBackTests.cs b/OracleProxy.Test/OracleConnectionProxyTests/FallBackTests.cs deleted file mode 100644 index 88df0f7..0000000 --- a/OracleProxy.Test/OracleConnectionProxyTests/FallBackTests.cs +++ /dev/null @@ -1,80 +0,0 @@ -using DbProxy; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Data.Common; -using System.Threading.Tasks; - -namespace OracleProxy.Test.SqlConnectionProxyTests -{ - [TestClass] - public class FallBackTests - { - private class FakeDbException : DbException { } - private OracleConnectionProxy _proxy; - - private string[] _connectionStrings = new string[] - { - "Data Source=MyOracleDB;Integrated Security=yes;", - "Data Source=MyOracleDB1;Integrated Security=yes;" - }; - - [TestInitialize] - public void Initialize() - { - _proxy = new OracleConnectionProxy(_connectionStrings, connectionOption: ConnectionOption.Fallback); - } - - [TestMethod] - public async Task Exception() - { - var connectionStrings = new List(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(_connectionStrings.Length, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - Assert.AreEqual(_connectionStrings[1], connectionStrings[1]); - - connectionStrings.Clear(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(_connectionStrings.Length, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - Assert.AreEqual(_connectionStrings[1], connectionStrings[1]); - } - - [TestMethod] - public async Task NoException() - { - var connectionStrings = new List(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - - connectionStrings.Clear(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - } - } -} diff --git a/OracleProxy.Test/OracleConnectionProxyTests/FirstConnectionOnlyTests.cs b/OracleProxy.Test/OracleConnectionProxyTests/FirstConnectionOnlyTests.cs deleted file mode 100644 index f9a4980..0000000 --- a/OracleProxy.Test/OracleConnectionProxyTests/FirstConnectionOnlyTests.cs +++ /dev/null @@ -1,76 +0,0 @@ -using DbProxy; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace OracleProxy.Test.SqlConnectionProxyTests -{ - [TestClass] - public class FirstConnectionOnlyTests - { - private OracleConnectionProxy _proxy; - - private string[] _connectionStrings = new string[] - { - "Data Source=MyOracleDB;Integrated Security=yes;", - "Data Source=MyOracleDB1;Integrated Security=yes;" - }; - - [TestInitialize] - public void Initialize() - { - _proxy = new OracleConnectionProxy(_connectionStrings, connectionOption: ConnectionOption.FirstOnly); - } - - [TestMethod] - public async Task Exception() - { - var connectionStrings = new List(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - - connectionStrings.Clear(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - } - - [TestMethod] - public async Task NoException() - { - var connectionStrings = new List(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - - connectionStrings.Clear(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - } - } -} diff --git a/OracleProxy.Test/OracleConnectionProxyTests/RetrySqlExceptionTests.cs b/OracleProxy.Test/OracleConnectionProxyTests/RetrySqlExceptionTests.cs deleted file mode 100644 index f23c459..0000000 --- a/OracleProxy.Test/OracleConnectionProxyTests/RetrySqlExceptionTests.cs +++ /dev/null @@ -1,73 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Data.Common; -using System.Data.OracleClient; -using System.Runtime.Serialization; -using System.Threading.Tasks; - -namespace OracleProxy.Test.SqlConnectionProxyTests -{ - [TestClass] - public class RetrySqlExceptionTests - { - private class FakeDbException : DbException { } - private OracleConnectionProxy _proxy; - private int maxAttempts = 3; - - private string[] _connectionStrings = - { - "Data Source=MyOracleDB;Integrated Security=yes;" - }; - - [TestInitialize] - public void Initialize() - { - _proxy = new OracleConnectionProxy(_connectionStrings, maxAttempts: maxAttempts); - } - - [TestMethod] - public async Task GenericException() - { - var count = 0; - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - count++; - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(1, count); - } - - [TestMethod] - public async Task SqlException() - { - var count = 0; - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - var exception = Instantiate(); - - count++; - return await Task.FromException(exception); - }) - ); - - Assert.AreEqual(maxAttempts, count); - } - - [TestMethod] - public async Task NoException() - { - var count = 0; - await _proxy.RunAsync(async (con) => - { - count++; - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, count); - } - - private T Instantiate() where T : class => FormatterServices.GetUninitializedObject(typeof(T)) as T; - } -} diff --git a/OracleProxy.Test/OracleConnectionProxyTests/RoundRobinTests.cs b/OracleProxy.Test/OracleConnectionProxyTests/RoundRobinTests.cs deleted file mode 100644 index e3adb23..0000000 --- a/OracleProxy.Test/OracleConnectionProxyTests/RoundRobinTests.cs +++ /dev/null @@ -1,97 +0,0 @@ -using DbProxy; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace OracleProxy.Test.SqlConnectionProxyTests -{ - [TestClass] - public class RoundRobinTests - { - private OracleConnectionProxy _proxy; - - private string[] _connectionStrings = new string[] - { - "Data Source=MyOracleDB;Integrated Security=yes;", - "Data Source=MyOracleDB1;Integrated Security=yes;" - }; - - [TestInitialize] - public void Initialize() - { - _proxy = new OracleConnectionProxy(_connectionStrings, connectionOption: ConnectionOption.RoundRobin); - } - - [TestMethod] - public async Task Exception() - { - var connectionStrings = new List(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - - connectionStrings.Clear(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[1], connectionStrings[0]); - - connectionStrings.Clear(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - } - - [TestMethod] - public async Task NoException() - { - var connectionStrings = new List(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - - connectionStrings.Clear(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[1], connectionStrings[0]); - - connectionStrings.Clear(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - } - } -} diff --git a/OracleProxy.Test/OracleConnectionProxyTests/RoundRobinWithFallbackTests.cs b/OracleProxy.Test/OracleConnectionProxyTests/RoundRobinWithFallbackTests.cs deleted file mode 100644 index 7248d99..0000000 --- a/OracleProxy.Test/OracleConnectionProxyTests/RoundRobinWithFallbackTests.cs +++ /dev/null @@ -1,100 +0,0 @@ -using DbProxy; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace OracleProxy.Test.SqlConnectionProxyTests -{ - [TestClass] - public class RoundRobinWithFallbackTests - { - private OracleConnectionProxy _proxy; - - private string[] _connectionStrings = new string[] - { - "Data Source=MyOracleDB;Integrated Security=yes;", - "Data Source=MyOracleDB1;Integrated Security=yes;" - }; - - [TestInitialize] - public void Initialize() - { - _proxy = new OracleConnectionProxy(_connectionStrings, connectionOption: ConnectionOption.RoundRobinWithFallback); - } - - [TestMethod] - public async Task Exception() - { - var connectionStrings = new List(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(_connectionStrings.Length, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - Assert.AreEqual(_connectionStrings[1], connectionStrings[1]); - - connectionStrings.Clear(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(_connectionStrings.Length, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[1], connectionStrings[0]); - Assert.AreEqual(_connectionStrings[0], connectionStrings[1]); - - connectionStrings.Clear(); - await Assert.ThrowsExceptionAsync(() => _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromException(new Exception()); - }) - ); - - Assert.AreEqual(_connectionStrings.Length, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - Assert.AreEqual(_connectionStrings[1], connectionStrings[1]); - } - - [TestMethod] - public async Task NoException() - { - var connectionStrings = new List(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - - connectionStrings.Clear(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[1], connectionStrings[0]); - - connectionStrings.Clear(); - await _proxy.RunAsync(async (con) => - { - connectionStrings.Add(con.ConnectionString); - return await Task.FromResult(0); - }); - - Assert.AreEqual(1, connectionStrings.Count); - Assert.AreEqual(_connectionStrings[0], connectionStrings[0]); - } - } -} diff --git a/OracleProxy.Test/OracleProxy.Test.csproj b/OracleProxy.Test/OracleProxy.Test.csproj deleted file mode 100644 index a69924a..0000000 --- a/OracleProxy.Test/OracleProxy.Test.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - netcoreapp2.0 - - false - - - - - - - - - - - - - diff --git a/OracleProxy/IOracleProxy.cs b/OracleProxy/IOracleProxy.cs deleted file mode 100644 index b4a0020..0000000 --- a/OracleProxy/IOracleProxy.cs +++ /dev/null @@ -1,9 +0,0 @@ -using DbProxy; -using System.Data.OracleClient; - -namespace OracleProxy -{ - public interface IOracleProxy : IDbProxy - { - } -} \ No newline at end of file diff --git a/OracleProxy/OracleConnectionProxy.cs b/OracleProxy/OracleConnectionProxy.cs deleted file mode 100644 index b169d98..0000000 --- a/OracleProxy/OracleConnectionProxy.cs +++ /dev/null @@ -1,19 +0,0 @@ -using DbProxy; -using System.Data.OracleClient; - -namespace OracleProxy -{ - public class OracleConnectionProxy : DbConnectionProxy, IOracleProxy - { - public OracleConnectionProxy(string connectionString) - : base(connectionString) - { } - - public OracleConnectionProxy(string[] connectionStrings, ConnectionOption connectionOption = ConnectionOption.FirstOnly, int maxAttempts = 1) - : base(connectionStrings, connectionOption, maxAttempts) - { - } - - protected override OracleConnection GetConnection(string connectionString) => new OracleConnection(connectionString); - } -} diff --git a/OracleProxy/OracleProxy.csproj b/OracleProxy/OracleProxy.csproj deleted file mode 100644 index 4197e8c..0000000 --- a/OracleProxy/OracleProxy.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - netstandard2.0 - - - - - - - - - - - diff --git a/SqlProxy/SqlConnectionProxy.cs b/SqlProxy/SqlConnectionProxy.cs index dcd89bc..43ce99e 100644 --- a/SqlProxy/SqlConnectionProxy.cs +++ b/SqlProxy/SqlConnectionProxy.cs @@ -11,8 +11,7 @@ public SqlConnectionProxy(string connectionString) public SqlConnectionProxy(string[] connectionStrings, ConnectionOption connectionOption = ConnectionOption.FirstOnly, int maxAttempts = 1) : base(connectionStrings, connectionOption, maxAttempts) - { - } + { } protected override SqlConnection GetConnection(string connectionString) => new SqlConnection(connectionString); }