diff --git a/NHibernate.SqlAzure.Tests/App.config b/NHibernate.SqlAzure.Tests/App.config index 8a02dea..8fead12 100644 --- a/NHibernate.SqlAzure.Tests/App.config +++ b/NHibernate.SqlAzure.Tests/App.config @@ -2,6 +2,7 @@ + diff --git a/NHibernate.SqlAzure.Tests/Config/FluentRunner.cs b/NHibernate.SqlAzure.Tests/Config/FluentRunner.cs index ff166e8..84f3f51 100644 --- a/NHibernate.SqlAzure.Tests/Config/FluentRunner.cs +++ b/NHibernate.SqlAzure.Tests/Config/FluentRunner.cs @@ -42,7 +42,11 @@ private void Execute() Database = _database, Task = _task, Connection = _connectionString, +#if NET45 Target = _migrationAssembly.CodeBase.Replace("file:///", ""), +#else + Targets = new string[] { _migrationAssembly.CodeBase.Replace("file:///", "") }, +#endif Version = _version }; diff --git a/NHibernate.SqlAzure.Tests/Config/NHibernateConfiguration.cs b/NHibernate.SqlAzure.Tests/Config/NHibernateConfiguration.cs index 24b387c..cf827f0 100644 --- a/NHibernate.SqlAzure.Tests/Config/NHibernateConfiguration.cs +++ b/NHibernate.SqlAzure.Tests/Config/NHibernateConfiguration.cs @@ -14,16 +14,21 @@ public class NHibernateConfiguration where T : SqlClientDriver { private readonly string _connectionString; private readonly IPersistenceConfigurer _databaseConfig; + private readonly bool _useNHibernateProfiler; - public NHibernateConfiguration(string connectionString, IPersistenceConfigurer databaseConfig = null) + public NHibernateConfiguration(string connectionString, IPersistenceConfigurer databaseConfig = null, bool useNHibernateProfiler = false) { _connectionString = connectionString; _databaseConfig = databaseConfig ?? MsSqlConfiguration.MsSql2008.ConnectionString(_connectionString).Driver(); + _useNHibernateProfiler = useNHibernateProfiler; } public ISessionFactory GetSessionFactory() { - NHibernateProfiler.Initialize(); + if (_useNHibernateProfiler) + { + NHibernateProfiler.Initialize(); + } var config = Fluently.Configure() .Database(_databaseConfig) diff --git a/NHibernate.SqlAzure.Tests/Config/NHibernateTestBase.cs b/NHibernate.SqlAzure.Tests/Config/NHibernateTestBase.cs index dfc3eba..e729b32 100644 --- a/NHibernate.SqlAzure.Tests/Config/NHibernateTestBase.cs +++ b/NHibernate.SqlAzure.Tests/Config/NHibernateTestBase.cs @@ -33,8 +33,12 @@ public abstract class NHibernateTestBase where T: SqlClientDriver protected FluentRunner Migrator; protected abstract string ConnectionString { get; } + protected bool UseNHibernateProfiler + { + get { return bool.Parse(ConfigurationManager.AppSettings["UseNHibernateProfiler"]); } + } - [TestFixtureSetUp] + [OneTimeSetUp] public void TestFixtureSetup() { CreateTestDatabase(); @@ -46,7 +50,7 @@ public void TestFixtureSetup() Migrator.MigrateToLatest(); - var nHibernateConfig = new NHibernateConfiguration(ConnectionString); + var nHibernateConfig = new NHibernateConfiguration(ConnectionString, useNHibernateProfiler: UseNHibernateProfiler); _sessionFactory = nHibernateConfig.GetSessionFactory(); } diff --git a/NHibernate.SqlAzure.Tests/NHibernate.SqlAzure.Tests.csproj b/NHibernate.SqlAzure.Tests/NHibernate.SqlAzure.Tests.csproj index 2579285..72c026a 100644 --- a/NHibernate.SqlAzure.Tests/NHibernate.SqlAzure.Tests.csproj +++ b/NHibernate.SqlAzure.Tests/NHibernate.SqlAzure.Tests.csproj @@ -1,146 +1,36 @@ - - + - Debug - AnyCPU - 8.0.30703 - 2.0 - {887FD0A4-B8E0-4B3D-BF7E-4CC7090EB829} - Library - Properties - NHibernate.SqlAzure.Tests - NHibernate.SqlAzure.Tests - v4.5 - 512 - ..\ - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false + net45 + NHibernate.SqlAzure.Tests + NHibernate.SqlAzure.Tests + Copyright © 2012 - - False - ..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll - - - False - ..\packages\FluentMigrator.1.1.2.1\lib\40\FluentMigrator.dll - - - False - ..\packages\FluentMigrator.Runner.1.1.1.26\lib\NET40\FluentMigrator.Runner.dll - - - False - ..\packages\FluentNHibernate.1.4.0.0\lib\net35\FluentNHibernate.dll - - - False - ..\packages\NHibernateProfiler.1.0.0.951\lib\Net40\HibernatingRhinos.Profiler.Appender.v4.0.dll - - - False - ..\packages\Iesi.Collections.3.2.0.4000\lib\Net35\Iesi.Collections.dll - - - ..\packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll - - - ..\packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data.dll - - - True - ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - - False - ..\packages\NHibernate.3.3.3.4001\lib\Net35\NHibernate.dll - - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - - + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - - - - False - ..\packages\WebActivator.1.4.4\lib\net40\WebActivator.dll - - - - - - - - - - - - - - - - - - - - Designer - true - - - App.config - True - - - - - - {C51908DF-FAEA-4EAA-8F75-096346537C33} - NHibernate.SqlAzure - - + - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/NHibernate.SqlAzure.Tests/Properties/AssemblyInfo.cs b/NHibernate.SqlAzure.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 7cd6ce8..0000000 --- a/NHibernate.SqlAzure.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NHibernate.SqlAzure.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NHibernate.SqlAzure.Tests")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("372cfa0d-2ae7-485c-952a-c0bd7d6cf86f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NHibernate.SqlAzure.Tests/SqlClientDriverTests.cs b/NHibernate.SqlAzure.Tests/SqlClientDriverTests.cs index a75f1cb..e78a96f 100644 --- a/NHibernate.SqlAzure.Tests/SqlClientDriverTests.cs +++ b/NHibernate.SqlAzure.Tests/SqlClientDriverTests.cs @@ -55,53 +55,56 @@ class SqlAzureClientDriverWithTimeoutRetriesShould : SqlClientDriverShould { [Test] - [ExpectedException(typeof(ExpectedErrorException))] public void Fail_to_execute_non_batching_commands_during_temporary_shutdown_of_sql_server() { - try + Assert.Throws(() => { - using (TemporarilyShutdownSqlServerExpress()) + try { - for (var i = 0; i < 100; i++) + using (TemporarilyShutdownSqlServerExpress()) { - Insert_and_select_entity(); - Thread.Sleep(50); + for (var i = 0; i < 100; i++) + { + Insert_and_select_entity(); + Thread.Sleep(50); + } } } - } - catch (GenericADOException e) - { - Console.WriteLine(e); - throw new ExpectedErrorException(); - } - Assert.Fail("There was no exception when executing non batching commands during temporary shutdown of SQL server, but one was expected."); + catch (GenericADOException e) + { + Console.WriteLine(e); + throw new ExpectedErrorException(); + } + }, "There was no exception when executing non batching commands during temporary shutdown of SQL server, but one was expected."); } [Test] - [ExpectedException(typeof(ExpectedErrorException))] public void Fail_to_execute_batching_commands_during_temporary_shutdown_of_sql_server() { - try + Assert.Throws(() => { - using (TemporarilyShutdownSqlServerExpress()) + try { - for (var i = 0; i < 100; i++) + using (TemporarilyShutdownSqlServerExpress()) { - Insert_and_select_multiple_entities(); - Thread.Sleep(50); + for (var i = 0; i < 100; i++) + { + Insert_and_select_multiple_entities(); + Thread.Sleep(50); + } } } - } - catch (GenericADOException e) - { - Console.WriteLine(e); - throw new ExpectedErrorException(); - } - catch (TransactionException e) - { - Console.WriteLine(e); - throw new ExpectedErrorException(); - } + catch (GenericADOException e) + { + Console.WriteLine(e); + throw new ExpectedErrorException(); + } + catch (TransactionException e) + { + Console.WriteLine(e); + throw new ExpectedErrorException(); + } + }); } public class ExpectedErrorException : Exception { } } @@ -237,7 +240,7 @@ public void Insert_and_update_multiple_entities() Assert.That(dbUsers, Has.Count.EqualTo(users.Count)); foreach (var u in dbUsers) { - Assert.That(u.Name, Is.StringEnding("_2_")); + Assert.That(u.Name, Does.EndWith("_2_")); } } } diff --git a/NHibernate.SqlAzure.Tests/TransientErrorDetectionTests.cs b/NHibernate.SqlAzure.Tests/TransientErrorDetectionTests.cs index 2483e7c..44e6af0 100644 --- a/NHibernate.SqlAzure.Tests/TransientErrorDetectionTests.cs +++ b/NHibernate.SqlAzure.Tests/TransientErrorDetectionTests.cs @@ -101,8 +101,8 @@ internal static class SqlExceptionGenerator public static SqlException GetSqlException(int errorCode) { var collection = (SqlErrorCollection)Activator.CreateInstance(typeof(SqlErrorCollection), true); - var error = (SqlError)Activator.CreateInstance(typeof(SqlError), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { errorCode, (byte)2, (byte)3, "server name", "error message", "proc", 100 }, null); - + var error = (SqlError)Activator.CreateInstance(typeof(SqlError), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { errorCode, (byte)2, (byte)3, "server name", "error message", "proc", 100, (Exception)null }, null); + typeof(SqlErrorCollection) .GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Instance) .Invoke(collection, new object[] { error }); diff --git a/NHibernate.SqlAzure.Tests/packages.config b/NHibernate.SqlAzure.Tests/packages.config deleted file mode 100644 index 1934931..0000000 --- a/NHibernate.SqlAzure.Tests/packages.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/NHibernate.SqlAzure.sln b/NHibernate.SqlAzure.sln index fdd1e9a..36766c3 100644 --- a/NHibernate.SqlAzure.sln +++ b/NHibernate.SqlAzure.sln @@ -13,15 +13,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution README.md = README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate.SqlAzure.Tests", "NHibernate.SqlAzure.Tests\NHibernate.SqlAzure.Tests.csproj", "{887FD0A4-B8E0-4B3D-BF7E-4CC7090EB829}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate.SqlAzure.Tests", "NHibernate.SqlAzure.Tests\NHibernate.SqlAzure.Tests.csproj", "{887FD0A4-B8E0-4B3D-BF7E-4CC7090EB829}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate4.SqlAzure", "NHibernate4.SqlAzure\NHibernate4.SqlAzure.csproj", "{BF649532-3E8A-4DC7-9F43-9AB25E475BF8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate4.SqlAzure.Tests", "NHibernate4.SqlAzure.Tests\NHibernate4.SqlAzure.Tests.csproj", "{4864689E-5B40-4EA2-A797-63B2AEBFE5DC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate4.SqlAzure.Tests", "NHibernate4.SqlAzure.Tests\NHibernate4.SqlAzure.Tests.csproj", "{4864689E-5B40-4EA2-A797-63B2AEBFE5DC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate5.SqlAzure", "NHibernate5.SqlAzure\NHibernate5.SqlAzure.csproj", "{895B6F59-B5BE-4796-847D-C3FF2C7EED66}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate5.SqlAzure", "NHibernate5.SqlAzure\NHibernate5.SqlAzure.csproj", "{895B6F59-B5BE-4796-847D-C3FF2C7EED66}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHibernate5.SqlAzure.Tests", "NHibernate5.SqlAzure.Tests\NHibernate5.SqlAzure.Tests.csproj", "{BF71D707-D321-40DB-97CB-3A3A02F345D5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHibernate5.SqlAzure.Tests", "NHibernate5.SqlAzure.Tests\NHibernate5.SqlAzure.Tests.csproj", "{BF71D707-D321-40DB-97CB-3A3A02F345D5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build-common", "build-common", "{1D8F31F4-C15B-4DF2-9636-7585232461AD}" + ProjectSection(SolutionItems) = preProject + build-common\NHibernate.SqlAzure.props = build-common\NHibernate.SqlAzure.props + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/NHibernate4.SqlAzure.Tests/App.config b/NHibernate4.SqlAzure.Tests/App.config index 70cd75e..2c85d5e 100644 --- a/NHibernate4.SqlAzure.Tests/App.config +++ b/NHibernate4.SqlAzure.Tests/App.config @@ -2,6 +2,7 @@ + diff --git a/NHibernate4.SqlAzure.Tests/NHibernate4.SqlAzure.Tests.csproj b/NHibernate4.SqlAzure.Tests/NHibernate4.SqlAzure.Tests.csproj index 6cc16af..223c7bc 100644 --- a/NHibernate4.SqlAzure.Tests/NHibernate4.SqlAzure.Tests.csproj +++ b/NHibernate4.SqlAzure.Tests/NHibernate4.SqlAzure.Tests.csproj @@ -1,110 +1,45 @@ - - - + - Debug - AnyCPU - {4864689E-5B40-4EA2-A797-63B2AEBFE5DC} - Library - Properties - NHibernate4.SqlAzure.Tests - NHibernate4.SqlAzure.Tests - v4.5 - 512 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + net45 + false + NHibernate4.SqlAzure.Tests + NHibernate4.SqlAzure.Tests + Copyright © 2015 + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - ..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll - - - ..\packages\FluentMigrator.1.1.2.1\lib\40\FluentMigrator.dll - - - ..\packages\FluentMigrator.Runner.1.1.1.26\lib\NET40\FluentMigrator.Runner.dll - - - False - ..\packages\FluentNHibernate.2.0.1.0\lib\net40\FluentNHibernate.dll - - - ..\packages\NHibernateProfiler.1.0.0.951\lib\Net40\HibernatingRhinos.Profiler.Appender.v4.0.dll - - - ..\packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll - - - ..\packages\NHibernate.4.1.0.4000\lib\net40\NHibernate.dll - True - - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll - - - - - - - - + + + - - Designer - true - - - App.config - True - - - Designer - + - - {bf649532-3e8a-4dc7-9f43-9ab25e475bf8} - NHibernate4.SqlAzure - + - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/NHibernate4.SqlAzure.Tests/Properties/AssemblyInfo.cs b/NHibernate4.SqlAzure.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 007fd21..0000000 --- a/NHibernate4.SqlAzure.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NHibernate4.SqlAzure.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NHibernate4.SqlAzure.Tests")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4864689e-5b40-4ea2-a797-63b2aebfe5dc")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NHibernate4.SqlAzure.Tests/packages.config b/NHibernate4.SqlAzure.Tests/packages.config deleted file mode 100644 index d7e0d74..0000000 --- a/NHibernate4.SqlAzure.Tests/packages.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/NHibernate5.SqlAzure.Tests/App.config b/NHibernate5.SqlAzure.Tests/App.config index 2865826..47c76b0 100644 --- a/NHibernate5.SqlAzure.Tests/App.config +++ b/NHibernate5.SqlAzure.Tests/App.config @@ -2,6 +2,7 @@ + diff --git a/NHibernate5.SqlAzure.Tests/App_Start/NHibernateProfilerBootstrapper.cs b/NHibernate5.SqlAzure.Tests/App_Start/NHibernateProfilerBootstrapper.cs deleted file mode 100644 index 8b00753..0000000 --- a/NHibernate5.SqlAzure.Tests/App_Start/NHibernateProfilerBootstrapper.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HibernatingRhinos.Profiler.Appender.NHibernate; - -// If you're using .NET Core please remove this line and call NHibernateProfiler.Initialize(); on the very beginning of your application. -[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(NHibernate5.SqlAzure.Tests.App_Start.NHibernateProfilerBootstrapper), "PreStart")] -namespace NHibernate5.SqlAzure.Tests.App_Start -{ - public static class NHibernateProfilerBootstrapper - { - public static void PreStart() - { - // Initialize the profiler - NHibernateProfiler.Initialize(); - - // You can also use the profiler in an offline manner. - // This will generate a file with a snapshot of all the NHibernate activity in the application, - // which you can use for later analysis by loading the file into the profiler. - // var filename = @"c:\profiler-log"; - // NHibernateProfiler.InitializeOfflineProfiling(filename); - - // You can use the following for production profiling. - // NHibernateProfiler.InitializeForProduction(11234, "A strong password like: ze38r/b2ulve2HLQB8NK5AYig"); - } - } -} - diff --git a/NHibernate5.SqlAzure.Tests/App_Start/NHibernateProfilerBootstrapper.vb b/NHibernate5.SqlAzure.Tests/App_Start/NHibernateProfilerBootstrapper.vb deleted file mode 100644 index 7fc7edb..0000000 --- a/NHibernate5.SqlAzure.Tests/App_Start/NHibernateProfilerBootstrapper.vb +++ /dev/null @@ -1,22 +0,0 @@ -Imports HibernatingRhinos.Profiler.Appender.NHibernate - -' If you're using .NET Core please remove this line and call NHibernateProfiler.Initialize() on the very beginning of your application. - -Namespace App_Start - Public Class NHibernateProfilerBootstrapper - Public Shared Sub PreStart() - ' Initialize the profiler - NHibernateProfiler.Initialize() - - ' You can also use the profiler in an offline manner. - ' This will generate a file with a snapshot of all the NHibernate activity in the application, - ' which you can use for later analysis by loading the file into the profiler. - ' Dim FileName as String = @"c:\profiler-log"; - ' NHibernateProfiler.InitializeOfflineProfiling(FileName) - - ' You can use the following for production profiling. - ' NHibernateProfiler.InitializeForProduction(11234, "A strong password like: ze38r/b2ulve2HLQB8NK5AYig"); - End Sub - End Class -End Namespace - diff --git a/NHibernate5.SqlAzure.Tests/NHibernate5.SqlAzure.Tests.csproj b/NHibernate5.SqlAzure.Tests/NHibernate5.SqlAzure.Tests.csproj index 0403260..9b63ba4 100644 --- a/NHibernate5.SqlAzure.Tests/NHibernate5.SqlAzure.Tests.csproj +++ b/NHibernate5.SqlAzure.Tests/NHibernate5.SqlAzure.Tests.csproj @@ -1,172 +1,50 @@ - - + + + - Debug - AnyCPU - {BF71D707-D321-40DB-97CB-3A3A02F345D5} - Library - Properties - NHibernate5.SqlAzure.Tests - NHibernate5.SqlAzure.Tests - v4.6.1 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + net461;netcoreapp3.1 + NHibernate5.SqlAzure.Tests + NHibernate5.SqlAzure.Tests + Copyright © 2018 + + + + + + - - ..\packages\Antlr3.Runtime.3.5.1\lib\net40-client\Antlr3.Runtime.dll - - - ..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll - - - ..\packages\FluentMigrator.1.1.2.1\lib\40\FluentMigrator.dll - - - ..\packages\FluentMigrator.Runner.1.1.1.26\lib\NET40\FluentMigrator.Runner.dll - - - ..\packages\FluentNHibernate.2.0.3.0\lib\net40\FluentNHibernate.dll - - - ..\packages\NHibernateProfiler.5.0.5044\lib\net46\HibernatingRhinos.Profiler.Appender.dll - - - ..\packages\Iesi.Collections.4.0.4\lib\net461\Iesi.Collections.dll - - - - ..\packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll - - - ..\packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data.dll - - - ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - - ..\packages\NHibernate.5.2.3\lib\net461\NHibernate.dll - - - ..\packages\NUnit.2.6.2\lib\nunit.framework.dll - - - ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - - ..\packages\Remotion.Linq.EagerFetching.2.2.0\lib\net45\Remotion.Linq.EagerFetching.dll - - - - - - - - ..\packages\System.Diagnostics.DiagnosticSource.4.4.1\lib\net46\System.Diagnostics.DiagnosticSource.dll - - + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - ..\packages\WebActivator.1.4.4\lib\net40\WebActivator.dll - - - ..\packages\WebActivatorEx.2.0.5\lib\net40\WebActivatorEx.dll - - - - FluentRunner.cs - - - LocalTestingReliableSql2008ClientDriver.cs - - - NHibernateConfiguration.cs - - - NHibernateTestBase.cs - - - SqlExpressTransientErrorDetectionStrategy.cs - - - ConnectionTests.cs - - - User.cs - - - UserProperty.cs - - - 20120801141148_CreateUserTable.cs - - - 20120809201500_CreateUserPropertyTable.cs - - - SqlClientDriverTests.cs - - - TransientErrorDetectionTests.cs - - - + + + - - Designer - true - - - App.config - True - - - Designer - + + - - {895b6f59-b5be-4796-847d-c3ff2c7eed66} - NHibernate5.SqlAzure - + - + - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - \ No newline at end of file diff --git a/NHibernate5.SqlAzure.Tests/Properties/AssemblyInfo.cs b/NHibernate5.SqlAzure.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index a62b076..0000000 --- a/NHibernate5.SqlAzure.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("NHibernate5.SqlAzure.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NHibernate5.SqlAzure.Tests")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: Guid("bf71d707-d321-40db-97cb-3a3a02f345d5")] - -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NHibernate5.SqlAzure.Tests/packages.config b/NHibernate5.SqlAzure.Tests/packages.config deleted file mode 100644 index e6448bf..0000000 --- a/NHibernate5.SqlAzure.Tests/packages.config +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/NHibernate5.SqlAzure/NHibernate5.SqlAzure.Standalone.nuspec b/NHibernate5.SqlAzure/NHibernate5.SqlAzure.Standalone.nuspec index 8324a03..a2e38a7 100644 --- a/NHibernate5.SqlAzure/NHibernate5.SqlAzure.Standalone.nuspec +++ b/NHibernate5.SqlAzure/NHibernate5.SqlAzure.Standalone.nuspec @@ -5,7 +5,7 @@ NHibernate5.SqlAzure.Standalone - 2.0.0 + $version$ Robert Moore, Matthew Davies @@ -33,15 +33,17 @@ en-US - - - + + + + - - - - + + + + + diff --git a/NHibernate5.SqlAzure/NHibernate5.SqlAzure.csproj b/NHibernate5.SqlAzure/NHibernate5.SqlAzure.csproj index 5333aeb..c18f316 100644 --- a/NHibernate5.SqlAzure/NHibernate5.SqlAzure.csproj +++ b/NHibernate5.SqlAzure/NHibernate5.SqlAzure.csproj @@ -1,120 +1,65 @@ - - - + + + - Debug - AnyCPU - {895B6F59-B5BE-4796-847D-C3FF2C7EED66} - Library - Properties + netstandard2.0 NHibernate.SqlAzure NHibernate.SqlAzure - v4.6.1 - 512 + NHibernate5.SqlAzure + NHibernate5.SqlAzure + Copyright © 2018 + true + true - - true + + + full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\NHibernate.SqlAzure.xml - + pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\NHibernate.SqlAzure.xml + + + + "$(ILMergeConsolePath)" /target:library ^ + "$(TargetPath)" ^ + "$(TargetDir)Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll" ^ + "$(TargetDir)Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data.dll" ^ + /out:"$(TargetDir)Combined\NHibernate.SqlAzure.dll" + + + + + + + + NHibernate5.SqlAzure.nuspec + + + + $(NuspecProperties);version=$(GitVersion_SemVer) + + + - - ..\packages\Antlr3.Runtime.3.5.1\lib\net40-client\Antlr3.Runtime.dll - - - ..\packages\Iesi.Collections.4.0.4\lib\net461\Iesi.Collections.dll - - - ..\packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll - - - ..\packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data.dll - - - ..\packages\NHibernate.5.2.3\lib\net461\NHibernate.dll - - - ..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll - - - ..\packages\Remotion.Linq.EagerFetching.2.2.0\lib\net45\Remotion.Linq.EagerFetching.dll - - - - - - - - - - - - + + + + + + - - DefaultReliableSql2008ClientDriver.cs - - - ReliableAdoNetTransactionFactory.cs - - - ReliableAdoTransaction.cs - - - ReliableSqlClientBatchingBatcherFactory.cs - - - ReliableSqlDbConnection.cs - Component - - - SqlAzureTransientErrorDetectionStrategy.cs - - - SqlAzureTransientErrorDetectionStrategyWithTimeouts.cs - - - SqlAzureClientDriver.cs - - - SqlAzureClientDriverWithTimeoutRetries.cs - - - - - - - Component - + + + + + + + - - Designer - - - Designer - - + - - - mkdir "$(TargetDir)Combined" -"$(ProjectDir)..\packages\ilmerge.2.14.1208\tools\ILMerge.exe" /log:log.txt /v4 /target:library "$(TargetPath)" "$(TargetDir)Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll" "$(TargetDir)Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data.dll" /out:"$(TargetDir)Combined\NHibernate.SqlAzure.dll" -copy "$(TargetDir)NHibernate.SqlAzure.XML" "$(TargetDir)Combined\NHibernate.SqlAzure.XML" - \ No newline at end of file diff --git a/NHibernate5.SqlAzure/NHibernate5.SqlAzure.nuspec b/NHibernate5.SqlAzure/NHibernate5.SqlAzure.nuspec index 8458fc3..79bf423 100644 --- a/NHibernate5.SqlAzure/NHibernate5.SqlAzure.nuspec +++ b/NHibernate5.SqlAzure/NHibernate5.SqlAzure.nuspec @@ -5,7 +5,7 @@ NHibernate5.SqlAzure - 2.0.0 + $version$ Robert Moore, Matthew Davies @@ -33,13 +33,15 @@ en-US - + + - - - - + + + + + diff --git a/NHibernate5.SqlAzure/Properties/AssemblyInfo.cs b/NHibernate5.SqlAzure/Properties/AssemblyInfo.cs deleted file mode 100644 index 29a36fe..0000000 --- a/NHibernate5.SqlAzure/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("NHibernate5.SqlAzure")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NHibernate5.SqlAzure")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("895b6f59-b5be-4796-847d-c3ff2c7eed66")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NHibernate5.SqlAzure/ReliableSqlClientBatchingBatcher.cs b/NHibernate5.SqlAzure/ReliableSqlClientBatchingBatcher.cs index 5c3b2bb..8e0b6e7 100644 --- a/NHibernate5.SqlAzure/ReliableSqlClientBatchingBatcher.cs +++ b/NHibernate5.SqlAzure/ReliableSqlClientBatchingBatcher.cs @@ -1,4 +1,5 @@ -// Parts of this file were copied from NHibernate.AdoNet.SqlClientBatchingBatcherFactory, but modified to use ReliableSqlDbConnection +#if NETFX +// Parts of this file were copied from NHibernate.AdoNet.SqlClientBatchingBatcherFactory, but modified to use ReliableSqlDbConnection // The #regions indicate the copied code using System; using System.Data; @@ -17,15 +18,15 @@ namespace NHibernate.SqlAzure /// public class ReliableSqlClientBatchingBatcher : SqlClientBatchingBatcher { - #region Impersonate private fields in base class +#region Impersonate private fields in base class private readonly ConnectionManager _connectionManager; private readonly FieldInfo _totalExpectedRowsAffectedField = typeof(SqlClientBatchingBatcher) .GetField("_totalExpectedRowsAffected", BindingFlags.NonPublic | BindingFlags.Instance); - private readonly FieldInfo _currentBatchField = typeof (SqlClientBatchingBatcher) + private readonly FieldInfo _currentBatchField = typeof(SqlClientBatchingBatcher) .GetField("_currentBatch", BindingFlags.NonPublic | BindingFlags.Instance); private readonly FieldInfo _currentBatchCommandsLogField = typeof(SqlClientBatchingBatcher) .GetField("_currentBatchCommandsLog", BindingFlags.NonPublic | BindingFlags.Instance); - private readonly MethodInfo _createConfiguredBatchMethod = typeof (SqlClientBatchingBatcher) + private readonly MethodInfo _createConfiguredBatchMethod = typeof(SqlClientBatchingBatcher) .GetMethod("CreateConfiguredBatch", BindingFlags.Instance | BindingFlags.NonPublic); // ReSharper disable InconsistentNaming @@ -41,7 +42,7 @@ private SqlClientSqlCommandSet _currentBatch } private StringBuilder _currentBatchCommandsLog { - get { return (StringBuilder) _currentBatchCommandsLogField.GetValue(this); } + get { return (StringBuilder)_currentBatchCommandsLogField.GetValue(this); } set { _currentBatchCommandsLogField.SetValue(this, value); } } private int _batchSize @@ -54,17 +55,17 @@ private SqlClientSqlCommandSet CreateConfiguredBatch() { return (SqlClientSqlCommandSet)_createConfiguredBatchMethod.Invoke(this, null); } - + public ReliableSqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor) : base(connectionManager, interceptor) { _connectionManager = connectionManager; } - #endregion +#endregion public override void AddToBatch(IExpectation expectation) { - #region NHibernate code +#region NHibernate code _totalExpectedRowsAffected += expectation.ExpectedRowCount; DbCommand batchUpdate = CurrentCommand; Driver.AdjustCommand(batchUpdate); @@ -84,20 +85,20 @@ public override void AddToBatch(IExpectation expectation) { Log.Debug("Adding to batch:" + lineWithParameters); } - #endregion +#endregion _currentBatch.Append((System.Data.SqlClient.SqlCommand)(ReliableSqlCommand)batchUpdate); - #region NHibernate code +#region NHibernate code if (_currentBatch.CountOfCommands >= _batchSize) { ExecuteBatchWithTiming(batchUpdate); } - #endregion +#endregion } // Need this method call in this class rather than the base class to ensure Prepare is called... if only it was virtual :( protected void ExecuteBatch(IDbCommand ps) { - #region NHibernate code +#region NHibernate code Log.Debug("Executing batch"); CheckReaders(); Prepare(_currentBatch.BatchCommand); @@ -122,7 +123,7 @@ protected void ExecuteBatch(IDbCommand ps) _currentBatch.Dispose(); _totalExpectedRowsAffected = 0; _currentBatch = CreateConfiguredBatch(); - #endregion +#endregion } /// @@ -139,30 +140,30 @@ protected void ExecuteBatch(IDbCommand ps) { var sessionConnection = (ReliableSqlDbConnection)_connectionManager.GetConnection(); - #region NHibernate code +#region NHibernate code if (cmd.Connection != null) { // make sure the commands connection is the same as the Sessions connection // these can be different when the session is disconnected and then reconnected if (cmd.Connection != sessionConnection) { - cmd.Connection = (System.Data.SqlClient.SqlConnection) sessionConnection; + cmd.Connection = (System.Data.SqlClient.SqlConnection)sessionConnection; } } else { - cmd.Connection = (System.Data.SqlClient.SqlConnection) sessionConnection; + cmd.Connection = (System.Data.SqlClient.SqlConnection)sessionConnection; } _connectionManager.Transaction.Enlist(cmd); Driver.PrepareCommand(cmd); - #endregion +#endregion } catch (InvalidOperationException ioe) { - #region NHibernate code +#region NHibernate code throw new ADOException("While preparing " + cmd.CommandText + " an error occurred", ioe); - #endregion +#endregion } } @@ -172,4 +173,32 @@ protected override void DoExecuteBatch(DbCommand ps) ReliableAdoTransaction.ExecuteWithRetry(connection, () => ExecuteBatch(ps)); } } -} \ No newline at end of file +} +#else +using System.Data.Common; +using NHibernate.AdoNet; + +namespace NHibernate.SqlAzure +{ + /// + /// Exposes functionality when a + /// connection is being used. + /// + public class ReliableSqlClientBatchingBatcher : GenericBatchingBatcher + { + private readonly ConnectionManager _connectionManager; + + public ReliableSqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor) + : base(connectionManager, interceptor) + { + _connectionManager = connectionManager; + } + + protected override void DoExecuteBatch(DbCommand ps) + { + var connection = (ReliableSqlDbConnection)_connectionManager.GetConnection(); + ReliableAdoTransaction.ExecuteWithRetry(connection, () => base.DoExecuteBatch(ps)); + } + } +} +#endif \ No newline at end of file diff --git a/NHibernate5.SqlAzure/packages.config b/NHibernate5.SqlAzure/packages.config deleted file mode 100644 index fbe3c5d..0000000 --- a/NHibernate5.SqlAzure/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/build-common/NHibernate.SqlAzure.props b/build-common/NHibernate.SqlAzure.props new file mode 100644 index 0000000..a25cdb7 --- /dev/null +++ b/build-common/NHibernate.SqlAzure.props @@ -0,0 +1,17 @@ + + + + false + true + NETFX;$(DefineConstants) + + false + true + + true + snupkg + + + + + \ No newline at end of file diff --git a/packages/repositories.config b/packages/repositories.config index 2f519b1..95b7f06 100644 --- a/packages/repositories.config +++ b/packages/repositories.config @@ -1,9 +1,5 @@  - - - - \ No newline at end of file