diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..42f76707257 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,49 @@ +language: csharp +mono: none +dotnet: 2.1.2 +sudo: required +services: + - mysql + - postgresql + - docker +env: + - DB=SqlServer2008 CONNECTION_STRING="Server=localhost;initial catalog=nhibernate;User Id=sa;Password=P@ssw0rd;" + - DB=PostgreSQL CONNECTION_STRING="Host=localhost;Port=5432;Username=postgres;Database=nhibernate;Enlist=true;" + - DB=Firebird + - DB=MySQL CONNECTION_STRING="Server=127.0.0.1;Uid=root;Database=nhibernate;Old Guids=True;" +matrix: + allow_failures: + - env: DB=MySQL CONNECTION_STRING="Server=127.0.0.1;Uid=root;Database=nhibernate;Old Guids=True;" +before_install: + - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + - curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list + - sudo apt-get update -qq + - sudo apt-get install -y powershell + - |- + if [[ "$DB" == "MySQL" ]] + then + echo -e '[server]\nlower_case_table_names=1' | sudo tee -a /etc/mysql/my.cnf + sudo service mysql restart + fi + - |- + if [[ "$DB" == "Firebird" ]] + then + sudo apt-get install -y libicu-dev libtommath-dev curl + curl -L -O https://github.com/FirebirdSQL/firebird/releases/download/R3_0_3/Firebird-3.0.3.32900-0.amd64.tar.gz + tar xzvf Firebird-3.0.3.32900-0.amd64.tar.gz + pushd Firebird-3.0.3.32900-0.amd64 + sudo ./install.sh -silent + popd + export $(sudo cat /opt/firebird/SYSDBA.password | grep -v ^# | xargs) + sudo chmod 775 /tmp/firebird + echo -e "nhibernate = /tmp/firebird/nhibernate.fdb" | sudo tee -a /opt/firebird/databases.conf + echo -e "AuthServer = Srp\nAuthClient = Srp\nUserManager = Srp\nWireCrypt = Enabled" | sudo tee -a /opt/firebird/firebird.conf + sudo /opt/firebird/bin/gsec -modify SYSDBA -pw masterkey -admin yes + sudo service firebird restart + fi +before_script: + - if [[ "$DB" == "SqlServer2008" ]]; then docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=P@ssw0rd" -e "MSSQL_PID=Express" -p 1433:1433 -d --name sqlexpress microsoft/mssql-server-linux:latest; fi + - if [[ "$DB" == "PostgreSQL" ]]; then psql -c "CREATE DATABASE nhibernate;" -U postgres; fi + - if [[ "$DB" == "MySQL" ]]; then mysql -e "CREATE DATABASE IF NOT EXISTS nhibernate;"; fi +script: + - pwsh -noprofile -command "& ./build.ps1 -TaskList Set-Configuration,Test -properties @{\"Database\" = \"$DB\";\"ConnectionString\"=\"$CONNECTION_STRING\"}" diff --git a/Tools/packages.config b/Tools/packages.config index 7acb30d0a5c..fcfaf0c17fc 100644 --- a/Tools/packages.config +++ b/Tools/packages.config @@ -7,6 +7,6 @@ - + diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..75728550da9 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,66 @@ +version: 5.1.0.{build} +image: Visual Studio 2017 +environment: + matrix: + - DB: SqlServer2008 + CONNECTION_STRING: Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate; + - DB: PostgreSQL + CONNECTION_STRING: Host=localhost;Port=5432;Username=postgres;Password=Password12!;Database=nhibernate;Enlist=true; + - DB: Firebird + - DB: MySQL + CONNECTION_STRING: Server=127.0.0.1;Uid=root;Pwd=Password12!;Database=nhibernate;Old Guids=True; +init: + # Required for having windows endlines in sources zip + - git config --global core.autocrlf true +matrix: + allow_failures: + - DB: MySQL +build: off +before_test: +- ps: |- + switch ($env:DB) { + 'Firebird' { + $FireBirdPath = 'C:\firebird' + # Install Firebird + New-Item -ItemType Directory -Force $FireBirdPath > $null + Push-Location $FireBirdPath + Invoke-WebRequest 'https://github.com/FirebirdSQL/firebird/releases/download/R3_0_3/Firebird-3.0.3.32900-0_x64.zip' -OutFile firebird.zip + Unblock-File firebird.zip + 7z x firebird.zip + New-Item -ItemType Directory -Force Data + # Declare nhibernate db + Add-Content -Path '.\databases.conf' -Value "`r`nnhibernate = $FireBirdPath\Data\nhibernate.fdb" + # Minimal db settings + Add-Content -Path '.\firebird.conf' -Value "`r`nAuthServer = Srp`r`nAuthClient = Srp`r`nUserManager = Srp`r`nWireCrypt = Enabled" + # Create SYSDBA account + New-Item SYSDBA.sql -Type File + Add-Content -Path '.\SYSDBA.sql' -Value "CREATE USER SYSDBA PASSWORD 'masterkey';`r`nCOMMIT;`r`nQUIT;" + .\isql -user sysdba employee -input SYSDBA.sql + # Start Firebird + .\firebird.exe -a + Pop-Location + } + 'MySQL' { + Start-Service 'MySQL57' + # Create nhibernate database (not handled by NHibernate.TestDatabaseSetup.dll) + $env:MYSQL_PWD = 'Password12!' + & 'C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql' -e 'CREATE DATABASE nhibernate;' --user=root + } + 'Odbc' { Start-Service 'MSSQL$SQL2017' } + 'PostgreSQL' { + # Enable prepared transactions + Add-Content -Path 'C:\Program Files\PostgreSQL\10\data\postgresql.conf' -Value "`r`nmax_prepared_transactions = 100" + Start-Service 'postgresql-x64-10' + } + 'SqlServer2008' { Start-Service 'MSSQL$SQL2017' } + 'SqlServer2012' { Start-Service 'MSSQL$SQL2017' } + } +test_script: +- cmd: powershell -noprofile -command "& ./build.ps1 -TaskList Set-Configuration,Test -properties @{\"Database\" = \"%DB%\";\"ConnectionString\"=\"%CONNECTION_STRING%\"}" +deploy: off +on_finish: +- ps: |- + $wc = New-Object 'System.Net.WebClient' + Get-Item '*-TestResult.xml' | ForEach-Object { + $wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit3/$($env:APPVEYOR_JOB_ID)", $_) + } \ No newline at end of file diff --git a/build-common/NHibernate.props b/build-common/NHibernate.props index dda12d23d15..0edec5583ed 100644 --- a/build-common/NHibernate.props +++ b/build-common/NHibernate.props @@ -24,5 +24,7 @@ True + + True diff --git a/build-common/common.xml b/build-common/common.xml index 63cfa3f6558..491e9ba17d2 100644 --- a/build-common/common.xml +++ b/build-common/common.xml @@ -8,12 +8,6 @@ - - - @@ -29,10 +23,11 @@ + + - - + diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 00000000000..8fd7a987dec --- /dev/null +++ b/build.ps1 @@ -0,0 +1,9 @@ +param ( + $TaskList = 'Default', + [hashtable]$Properties = @{} +) + +Install-Module psake -Force -Scope CurrentUser +Import-Module psake +Invoke-psake -buildFile .\psake.ps1 -nologo -taskList $TaskList -properties $Properties +exit ( [int] ( -not $psake.build_success ) ) \ No newline at end of file diff --git a/default.build b/default.build index cfee357e231..b4d384f3bb3 100644 --- a/default.build +++ b/default.build @@ -16,7 +16,6 @@ - @@ -33,10 +32,8 @@ - - - + @@ -76,15 +73,6 @@ program="${async-generator-console}" /> - - - - - - - - - @@ -156,7 +144,7 @@ - + @@ -166,20 +154,17 @@ - - - - - - - - + + + + + + - + - - - - - - @@ -255,19 +234,19 @@ - + - + - + @@ -275,22 +254,30 @@ - - - + + - - - - - + + + + + + + + + + + + + + diff --git a/doc/NHibernate.ndoc.in b/doc/NHibernate.ndoc.in deleted file mode 100644 index 5be3799acf7..00000000000 --- a/doc/NHibernate.ndoc.in +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/NHibernate.shfbproj.template b/doc/NHibernate.shfbproj.template index 9e6b55671cf..9cdab8859ed 100644 --- a/doc/NHibernate.shfbproj.template +++ b/doc/NHibernate.shfbproj.template @@ -25,11 +25,9 @@ False ${project.version.numeric} - - - - - + + + diff --git a/doc/documentation.build b/doc/documentation.build index 32c673b8f53..86104ac767b 100644 --- a/doc/documentation.build +++ b/doc/documentation.build @@ -53,8 +53,8 @@ - - + + diff --git a/psake.ps1 b/psake.ps1 new file mode 100644 index 00000000000..b7805de344d --- /dev/null +++ b/psake.ps1 @@ -0,0 +1,117 @@ +properties { + $Database = "SqlServer2012"; + $ConnectionString = $null; +} + +Task Default -depends Build, Test + +Task Set-Configuration { + $configDir = (Join-Path '.' 'current-test-configuration') + #Configuration matrix + $allSettings = @{ + 'Firebird' = @{ + 'connection.connection_string' = 'DataSource=localhost;Database=nhibernate;User ID=SYSDBA;Password=masterkey;MaxPoolSize=200;'; + 'connection.driver_class' = 'NHibernate.Driver.FirebirdClientDriver'; + 'dialect' = 'NHibernate.Dialect.FirebirdDialect' + }; + 'MySQL' = @{ + 'connection.connection_string' = 'Server=127.0.0.1;Uid=root;Pwd=Password12!;Database=nhibernate;Old Guids=True;'; + 'connection.driver_class' = 'NHibernate.Driver.MySqlDataDriver'; + 'dialect' = 'NHibernate.Dialect.MySQL5Dialect' + }; + 'Odbc' = @{ + # The OdbcDriver inherits SupportsMultipleOpenReaders=true from DriverBase, which requires Mars_Connection=yes for SQL Server. + 'connection.connection_string' = 'Server=(local)\SQL2017;Uid=sa;Pwd=Password12!;Database=nhibernateOdbc;Driver={SQL Server Native Client 11.0};Mars_Connection=yes;'; + 'connection.driver_class' = 'NHibernate.Driver.OdbcDriver'; + 'odbc.explicit_datetime_scale' = '3'; + <# We need to use a dialect that avoids mapping DbType.Time to TIME on MSSQL. On modern SQL Server + this becomes TIME(7). Later, such values cannot be read back over ODBC. The + error we get is "System.ArgumentException : Unknown SQL type - SS_TIME_EX.". I don't know for certain + why this occurs, but MS docs do say that for a client "compiled using a version of SQL Server Native + Client prior to SQL Server 2008", TIME(7) cannot be converted back to the client. Assuming that .Net's + OdbcDriver would be considered a "client compiled with a previous version", it would make sense. Anyway, + using the MsSql2005Dialect avoids these test failures. #> + 'dialect' = 'NHibernate.Dialect.MsSql2005Dialect' + }; + 'PostgreSQL' = @{ + 'connection.connection_string' = 'Host=localhost;Port=5432;Username=postgres;Password=Password12!;Database=nhibernate;Enlist=true'; + 'connection.driver_class' = 'NHibernate.Driver.NpgsqlDriver'; + 'dialect' = 'NHibernate.Dialect.PostgreSQL83Dialect' + }; + 'SQLite' = @{ + <# + DateTimeFormatString allows to prevent storing the fact that written date was having kind UTC, + which dodges the undesirable time conversion to local done on reads by System.Data.SQLite. + See https://system.data.sqlite.org/index.html/tktview/44a0955ea344a777ffdbcc077831e1adc8b77a36 + and https://github.com/nhibernate/nhibernate-core/issues/1362 #> + # Please note the connection string is formated for putting the db file in $configDir. + 'connection.connection_string' = "Data Source=$configDir/NHibernate.db;DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF;"; + 'connection.driver_class' = 'NHibernate.Driver.SQLite20Driver'; + 'dialect' = 'NHibernate.Dialect.SQLiteDialect' + }; + 'SqlServerCe' = @{ + # Please note the connection string is formated for putting the db file in $configDir. + 'connection.connection_string' = "Data Source=$configDir/NHibernate.sdf;"; + 'connection.driver_class' = 'NHibernate.Driver.SqlServerCeDriver'; + 'command_timeout' = '0'; + 'dialect' = 'NHibernate.Dialect.MsSqlCe40Dialect' + }; + 'SqlServer2008' = @{ + 'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;' + }; + 'SqlServer2012' = @{ + 'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;'; + 'dialect' = 'NHibernate.Dialect.MsSql2012Dialect' + } + } + #Settings for current build + $settings = $allSettings[$Database] + + if (!$settings) { + Write-Warning "Unable to find $Database settings" + exit 1 + } + if (-not [String]::IsNullOrWhitespace($ConnectionString)) { + $settings['connection.connection_string'] = $ConnectionString + } + #Create settings file + $configFile = (Join-Path $configDir 'hibernate.cfg.xml') + New-Item $configDir -Type Directory + Copy-Item "$([IO.Path]::Combine('.', 'build-common', 'teamcity-hibernate.cfg.xml'))" $configFile + #Patch settings file + $config = [Xml] (Get-Content $configFile) + $allProps = $config.'hibernate-configuration'.'session-factory'.property + foreach($key in $settings.keys) + { + $value = $settings[$key] + $property = $allProps | Where-Object { $_.name -eq $key } + if (!$property) { + Write-Warning "Unable to find $key property" + exit 1 + } + $property.InnerText = $value + } + $config.Save($configFile) +} + +Task Build { + Exec { + dotnet ` + build ./src/NHibernate.sln ` + -f netcoreapp2.0 ` + -c Release + } +} + +Task Test -depends Build { + @( + 'NHibernate.TestDatabaseSetup', + 'NHibernate.Test', + 'NHibernate.Test.VisualBasic' + ) | ForEach-Object { + $assembly = [IO.Path]::Combine("src", $_, "bin", "Release", "netcoreapp2.0", "$_.dll") + Exec { + dotnet $assembly --labels=before --nocolor "--result=$_-TestResult.xml" + } + } +} \ No newline at end of file diff --git a/src/NHibernate.DomainModel/NHibernate.DomainModel.csproj b/src/NHibernate.DomainModel/NHibernate.DomainModel.csproj index 956dd6236e9..c13e3c10be9 100644 --- a/src/NHibernate.DomainModel/NHibernate.DomainModel.csproj +++ b/src/NHibernate.DomainModel/NHibernate.DomainModel.csproj @@ -2,10 +2,13 @@ The Domain Model used by the Unit Tests. - net461 + netstandard2.0;net461;netcoreapp2.0 true $(NoWarn);3001;3002;3003;3005 + + NETFX;$(DefineConstants) + diff --git a/src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj b/src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj index d95d8dd583e..42f5b373af4 100644 --- a/src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj +++ b/src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj @@ -2,15 +2,26 @@ The Visual Basic Unit Tests for NHibernate. - net461 + net461;netcoreapp2.0 true $(NoWarn);3001;3002;3003;3005 On On + + NETCOREAPP2_0,$(DefineConstants) + Exe + false + + + NET461,$(DefineConstants) + + + + @@ -20,6 +31,9 @@ + + + @@ -27,4 +41,4 @@ - + \ No newline at end of file diff --git a/src/NHibernate.Test.VisualBasic/Program.vb b/src/NHibernate.Test.VisualBasic/Program.vb new file mode 100644 index 00000000000..362743c97ef --- /dev/null +++ b/src/NHibernate.Test.VisualBasic/Program.vb @@ -0,0 +1,7 @@ +#If NETCOREAPP2_0 +Public Class Program + Public Shared Function Main(args As String()) As Integer + Return New NUnitLite.AutoRun(GetType(Program).Assembly).Execute(args) + End Function +End Class +#End If \ No newline at end of file diff --git a/src/NHibernate.Test/Ado/BatcherFixture.cs b/src/NHibernate.Test/Ado/BatcherFixture.cs index c3ddc1dd8f8..4d7e8107673 100644 --- a/src/NHibernate.Test/Ado/BatcherFixture.cs +++ b/src/NHibernate.Test/Ado/BatcherFixture.cs @@ -86,6 +86,7 @@ public void OneRoundTripUpdate() Cleanup(); } +#if NETFX [Test, Ignore("Not fixed yet.")] [Description("SqlClient: The batcher should run all different INSERT queries in only one roundtrip.")] public void SqlClientOneRoundTripForUpdateAndInsert() @@ -95,7 +96,7 @@ public void SqlClientOneRoundTripForUpdateAndInsert() FillDb(); - using(var sqlLog = new SqlLogSpy()) + using (var sqlLog = new SqlLogSpy()) using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { @@ -140,7 +141,7 @@ public void BatchedoutputShouldBeFormatted() Cleanup(); } - +#endif [Test] [Description("The batcher should run all DELETE queries in only one roundtrip.")] diff --git a/src/NHibernate.Test/App.config b/src/NHibernate.Test/App.config index 0db5a1028c3..d3965012af5 100644 --- a/src/NHibernate.Test/App.config +++ b/src/NHibernate.Test/App.config @@ -31,10 +31,9 @@ NHibernate.Dialect.MsSql2008Dialect NHibernate.Driver.Sql2008ClientDriver - TestConnectionString + Server=localhost\sqlexpress;Database=nhibernate;Integrated Security=SSPI NHibernate.Test.DebugConnectionProvider, NHibernate.Test ReadCommitted - NHibernate.Cache.HashtableCacheProvider, NHibernate true diff --git a/src/NHibernate.Test/Async/Ado/BatcherFixture.cs b/src/NHibernate.Test/Async/Ado/BatcherFixture.cs index 36ab6e40928..20c3cdc04fd 100644 --- a/src/NHibernate.Test/Async/Ado/BatcherFixture.cs +++ b/src/NHibernate.Test/Async/Ado/BatcherFixture.cs @@ -98,6 +98,7 @@ public async Task OneRoundTripUpdateAsync() await (CleanupAsync()); } +#if NETFX [Test, Ignore("Not fixed yet.")] [Description("SqlClient: The batcher should run all different INSERT queries in only one roundtrip.")] public async Task SqlClientOneRoundTripForUpdateAndInsertAsync() @@ -107,7 +108,7 @@ public async Task SqlClientOneRoundTripForUpdateAndInsertAsync() await (FillDbAsync()); - using(var sqlLog = new SqlLogSpy()) + using (var sqlLog = new SqlLogSpy()) using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { @@ -152,7 +153,7 @@ public async Task BatchedoutputShouldBeFormattedAsync() await (CleanupAsync()); } - +#endif [Test] [Description("The batcher should run all DELETE queries in only one roundtrip.")] diff --git a/src/NHibernate.Test/Async/CfgTest/ConfigurationSerializationTests.cs b/src/NHibernate.Test/Async/CfgTest/ConfigurationSerializationTests.cs index fcba99abee6..746468e7b7d 100644 --- a/src/NHibernate.Test/Async/CfgTest/ConfigurationSerializationTests.cs +++ b/src/NHibernate.Test/Async/CfgTest/ConfigurationSerializationTests.cs @@ -28,6 +28,8 @@ public class ConfigurationSerializationTestsAsync [Test] public async Task Basic_CRUD_should_workAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + Assembly assembly = Assembly.Load("NHibernate.DomainModel"); var cfg = new Configuration(); if (TestConfigurationHelper.hibernateConfigFile != null) diff --git a/src/NHibernate.Test/Async/ConnectionTest/AggressiveReleaseTest.cs b/src/NHibernate.Test/Async/ConnectionTest/AggressiveReleaseTest.cs index 5f96e80f92d..27a2e471bf5 100644 --- a/src/NHibernate.Test/Async/ConnectionTest/AggressiveReleaseTest.cs +++ b/src/NHibernate.Test/Async/ConnectionTest/AggressiveReleaseTest.cs @@ -58,6 +58,8 @@ protected override void Done() [Test] public async Task SerializationOnAfterStatementAggressiveReleaseAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + Prepare(); ISession s = GetSessionUnderTest(); Silly silly = new Silly("silly"); @@ -79,6 +81,8 @@ public async Task SerializationOnAfterStatementAggressiveReleaseAsync() [Test] public async Task SerializationFailsOnAfterStatementAggressiveReleaseWithOpenResourcesAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + Prepare(); ISession s = GetSessionUnderTest(); @@ -258,4 +262,4 @@ public async Task ConnectionMaintanenceDuringFlushAsync() Done(); } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs b/src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs index 582e9eb383d..2741141fae9 100644 --- a/src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs +++ b/src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs @@ -475,6 +475,8 @@ public async Task CloningCriteria_AddCount_RemoveOrderingAsync() [Test] public async Task DetachedCriteriaTestAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + DetachedCriteria dc = DetachedCriteria.For(typeof(Student)) .Add(Property.ForName("Name").Eq("Gavin King")) .AddOrder(Order.Asc("StudentNumber")) @@ -3036,4 +3038,4 @@ public async Task CanSetLockModeOnDetachedCriteriaAsync() } } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/Async/Criteria/DetachedCriteriaSerializable.cs b/src/NHibernate.Test/Async/Criteria/DetachedCriteriaSerializable.cs index 927b4d39192..f12a950be11 100644 --- a/src/NHibernate.Test/Async/Criteria/DetachedCriteriaSerializable.cs +++ b/src/NHibernate.Test/Async/Criteria/DetachedCriteriaSerializable.cs @@ -50,6 +50,8 @@ public Task DetachedCriteriaItSelfAsync() { try { + TestsContext.AssumeSystemTypeIsSerializable(); + DetachedCriteria dc = DetachedCriteria.For(typeof(Student)) .Add(Expression.Eq("Name", "Gavin King")); return SerializeAndListAsync(dc); @@ -63,6 +65,8 @@ public Task DetachedCriteriaItSelfAsync() [Test] public async Task ExecutableCriteriaAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + // All query below don't have sense, are only to test if all needed classes are serializable // Basic criterion diff --git a/src/NHibernate.Test/Async/DynamicProxyTests/InterfaceProxySerializationTests/ProxyFixture.cs b/src/NHibernate.Test/Async/DynamicProxyTests/InterfaceProxySerializationTests/ProxyFixture.cs index 554a5b02f53..99eec4a9543 100644 --- a/src/NHibernate.Test/Async/DynamicProxyTests/InterfaceProxySerializationTests/ProxyFixture.cs +++ b/src/NHibernate.Test/Async/DynamicProxyTests/InterfaceProxySerializationTests/ProxyFixture.cs @@ -106,6 +106,8 @@ public async Task ProxyAsync() [Test] public async Task ProxySerializeAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); IMyProxy ap = new MyProxyImpl {Id = 1, Name = "first proxy"}; await (s.SaveAsync(ap)); @@ -137,6 +139,8 @@ public async Task ProxySerializeAsync() [Test] public async Task SerializeNotFoundProxyAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); // this does not actually exists in db var notThere = (IMyProxy) await (s.LoadAsync(typeof (MyProxyImpl), 5)); @@ -150,4 +154,4 @@ public async Task SerializeNotFoundProxyAsync() s.Close(); } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/Async/Legacy/FooBarTest.cs b/src/NHibernate.Test/Async/Legacy/FooBarTest.cs index ce7e63c27ec..d148a732bf6 100644 --- a/src/NHibernate.Test/Async/Legacy/FooBarTest.cs +++ b/src/NHibernate.Test/Async/Legacy/FooBarTest.cs @@ -2644,6 +2644,8 @@ public async Task NewFlushingAsync() [Test] public async Task PersistCollectionsAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); ITransaction txn = s.BeginTransaction(); IEnumerator enumer = (await (s.CreateQuery("select count(*) from b in class Bar").EnumerableAsync())).GetEnumerator(); @@ -4654,6 +4656,8 @@ public async Task SaveDeleteAsync() [Test] public async Task ProxyArrayAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); GlarchProxy g = new Glarch(); Glarch g1 = new Glarch(); diff --git a/src/NHibernate.Test/Async/Legacy/MasterDetailTest.cs b/src/NHibernate.Test/Async/Legacy/MasterDetailTest.cs index bd003e036e5..3639e821c88 100644 --- a/src/NHibernate.Test/Async/Legacy/MasterDetailTest.cs +++ b/src/NHibernate.Test/Async/Legacy/MasterDetailTest.cs @@ -640,6 +640,8 @@ public async Task NamedQueryAsync() [Test] public async Task SerializationAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); Master m = new Master(); Detail d1 = new Detail(); diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH1632/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH1632/Fixture.cs index d1b38098ad5..95c3f37665a 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH1632/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH1632/Fixture.cs @@ -24,10 +24,8 @@ namespace NHibernate.Test.NHSpecificTest.NH1632 [TestFixture] public class FixtureAsync : BugTestCase { - public override string BugNumber - { - get { return "NH1632"; } - } + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver.SupportsSystemTransactions; protected override void Configure(Configuration configuration) { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2057/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2057/Fixture.cs index 866d12ad443..f9174131b3c 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2057/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2057/Fixture.cs @@ -10,6 +10,7 @@ using System.Threading; using System.Transactions; +using NHibernate.Engine; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH2057 @@ -18,6 +19,9 @@ namespace NHibernate.Test.NHSpecificTest.NH2057 [TestFixture] public class FixtureAsync : BugTestCase { + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver.SupportsSystemTransactions; + [Test] public async Task WillCloseWhenUsingDTCAsync() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2176/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2176/Fixture.cs index ad9036fc089..155d435188f 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2176/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2176/Fixture.cs @@ -10,6 +10,7 @@ using System; using System.Transactions; +using NHibernate.Engine; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH2176 @@ -18,6 +19,9 @@ namespace NHibernate.Test.NHSpecificTest.NH2176 [TestFixture] public class FixtureAsync : BugTestCase { + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver.SupportsSystemTransactions; + protected override void OnSetUp() { base.OnSetUp(); diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2420/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2420/Fixture.cs index 906b69792ae..0f71ee82087 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2420/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2420/Fixture.cs @@ -15,6 +15,7 @@ using System.Transactions; using NHibernate.Dialect; using NHibernate.Driver; +using NHibernate.Engine; using NUnit.Framework; using Environment = NHibernate.Cfg.Environment; @@ -25,15 +26,11 @@ namespace NHibernate.Test.NHSpecificTest.NH2420 [TestFixture] public class FixtureAsync : BugTestCase { - public override string BugNumber - { - get { return "NH2420"; } - } + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver.SupportsSystemTransactions; - protected override bool AppliesTo(Dialect.Dialect dialect) - { - return (dialect is MsSql2005Dialect); - } + protected override bool AppliesTo(Dialect.Dialect dialect) => + dialect is MsSql2005Dialect; private string FetchConnectionStringFromConfiguration() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2773/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2773/Fixture.cs index c375ef7bfbc..71955fca059 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2773/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2773/Fixture.cs @@ -50,6 +50,8 @@ protected override void OnTearDown() { [Test] public async Task DeserializedSession_ProxyType_ShouldBeEqualToOriginalProxyTypeAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + System.Type originalProxyType = null; System.Type deserializedProxyType = null; ISession deserializedSession = null; diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH2880/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH2880/Fixture.cs index e3c6fdca56b..711a56eed81 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH2880/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH2880/Fixture.cs @@ -45,6 +45,8 @@ protected override void OnSetUp() [Test] public async Task ProxiesFromDeserializedSessionsCanBeLoadedAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + MemoryStream sessionMemoryStream; using (ISession s = Sfi.OpenSession()) @@ -85,4 +87,4 @@ protected override void OnTearDown() } } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs index 75f13d1a623..052557dc4c0 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs @@ -42,11 +42,12 @@ protected override void Configure(Configuration configuration) } // Uses directly SqlConnection. - protected override bool AppliesTo(ISessionFactoryImplementor factory) - => factory.ConnectionProvider.Driver is SqlClientDriver && base.AppliesTo(factory); + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver is SqlClientDriver && + factory.ConnectionProvider.Driver.SupportsSystemTransactions; - protected override bool AppliesTo(Dialect.Dialect dialect) - => dialect is MsSql2000Dialect && base.AppliesTo(dialect); + protected override bool AppliesTo(Dialect.Dialect dialect) => + dialect is MsSql2000Dialect; protected override void OnSetUp() { diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3119/FixtureByCode.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3119/FixtureByCode.cs index 6a82be6b309..1ba5c197171 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3119/FixtureByCode.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3119/FixtureByCode.cs @@ -98,6 +98,8 @@ public async Task PocoComponentTuplizer_Instantiate_UsesReflectonOptimizerAsync( [Test] public async Task PocoComponentTuplizerOfDeserializedConfiguration_Instantiate_UsesReflectonOptimizerAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + MemoryStream configMemoryStream = new MemoryStream(); BinaryFormatter writer = new BinaryFormatter(); writer.Serialize(configMemoryStream, cfg); diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH317/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH317/Fixture.cs index 06f9419876c..aaa67246ae5 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH317/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH317/Fixture.cs @@ -38,6 +38,8 @@ protected override IList Mappings [Test] public async Task ProxySerializationAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + Node node = new Node(); node.Id = 1; node.Name = "Node 1"; @@ -72,4 +74,4 @@ public async Task ProxySerializationAsync() s.Close(); } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3487/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3487/Fixture.cs index ca898e1f342..f0c6605a88d 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3487/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3487/Fixture.cs @@ -64,6 +64,8 @@ protected override void OnTearDown() [Test] public async Task CanDeserializeSessionWithEntityHashCollisionAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + IFormatter formatter = new BinaryFormatter(); byte[] serializedSessionArray; @@ -91,4 +93,4 @@ public async Task CanDeserializeSessionWithEntityHashCollisionAsync() } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/Async/NHSpecificTest/NH3583/AutoFlushFixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/NH3583/AutoFlushFixture.cs index 1b3d8a12d40..70e7b321e91 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/NH3583/AutoFlushFixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/NH3583/AutoFlushFixture.cs @@ -61,9 +61,12 @@ public async Task ShouldAutoFlushWhenInExplicitTransactionAsync() Assert.That(result.Count, Is.EqualTo(1)); } } + [Test] public async Task ShouldAutoFlushWhenInDistributedTransactionAsync() { + Assume.That(Sfi.ConnectionProvider.Driver.SupportsSystemTransactions, Is.True); + using (new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) using (var session = OpenSession()) { diff --git a/src/NHibernate.Test/Async/ReadOnly/ReadOnlyCriteriaQueryTest.cs b/src/NHibernate.Test/Async/ReadOnly/ReadOnlyCriteriaQueryTest.cs index 9e070d7cd62..44491937c3b 100644 --- a/src/NHibernate.Test/Async/ReadOnly/ReadOnlyCriteriaQueryTest.cs +++ b/src/NHibernate.Test/Async/ReadOnly/ReadOnlyCriteriaQueryTest.cs @@ -1068,6 +1068,8 @@ public async Task SubselectAsync() [Test] public async Task DetachedCriteriaAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + DetachedCriteria dc = NHibernate.Criterion.DetachedCriteria.For() .Add(Property.ForName("Name").Eq("Gavin King")) .AddOrder(Order.Asc("StudentNumber")); diff --git a/src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs b/src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs index d7080e398ac..9e8f4dcf332 100644 --- a/src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs +++ b/src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs @@ -254,7 +254,6 @@ public async Task WhenConfiguredOnlyExplicitAutoQuoteAsync() // Test uses the default dialect driver, which will not accept Odbc or OleDb connection strings. if (typeof(OdbcDriver).IsAssignableFrom(driverClass) || typeof(OleDbDriver).IsAssignableFrom(driverClass)) Assert.Ignore("Test is not compatible with OleDb or ODBC driver connection strings"); - var configuredDialect = Dialect.Dialect.GetDialect(); if(!configuredDialect.DefaultProperties.ContainsKey(Environment.ConnectionDriver)) { diff --git a/src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs b/src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs index eb1d7d68b18..1ca828eef59 100644 --- a/src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs +++ b/src/NHibernate.Test/Async/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs @@ -59,6 +59,7 @@ public Task ShouldVerifySameTableAsync() } } +#if NETFX [Test, SetCulture("tr-TR"), SetUICulture("tr-TR")] public async Task ShouldVerifySameTableTurkishAsync() { @@ -87,6 +88,7 @@ public async Task ShouldVerifySameTableTurkishAsync() await (export.DropAsync(true, true)); } } +#endif [Test] public void ShouldNotVerifyModifiedTableAsync() diff --git a/src/NHibernate.Test/Async/TransformTests/AliasToBeanResultTransformerFixture.cs b/src/NHibernate.Test/Async/TransformTests/AliasToBeanResultTransformerFixture.cs index c28bf1381fa..a73832b77fa 100644 --- a/src/NHibernate.Test/Async/TransformTests/AliasToBeanResultTransformerFixture.cs +++ b/src/NHibernate.Test/Async/TransformTests/AliasToBeanResultTransformerFixture.cs @@ -257,6 +257,8 @@ public void ToPropertiesInsensitivelyDuplicated_WithoutAnyProjectionsAsync() [Test] public async Task SerializationAsync() { + TestsContext.AssumeSystemTypeIsSerializable(); + await (AssertSerializationAsync()); await (AssertSerializationAsync()); await (AssertSerializationAsync()); @@ -312,4 +314,4 @@ public async Task SerializationAsync() } } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs b/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs index f76dbecd9c0..ac18c80da72 100644 --- a/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs +++ b/src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs @@ -1,5 +1,6 @@ using System; using System.Configuration; +using System.Reflection; using NHibernate.Event; using NUnit.Framework; using NHibernate.Cfg; @@ -27,6 +28,8 @@ public void InvalidConfig() [Test] public void FromAppConfigTest() { + Assume.That(TestsContext.ExecutingWithVsTest, Is.False); + IHibernateConfiguration hc = ConfigurationManager.GetSection("hibernate-configuration") as IHibernateConfiguration; Assert.That(hc.ByteCodeProviderType, Is.EqualTo("lcg")); Assert.IsTrue(hc.UseReflectionOptimizer); @@ -36,6 +39,8 @@ public void FromAppConfigTest() [Test] public void IgnoreSystemOutOfAppConfig() { + Assume.That(TestsContext.ExecutingWithVsTest, Is.False); + IHibernateConfiguration hc = ConfigurationManager.GetSection("hibernate-configuration") as IHibernateConfiguration; string xml = @" diff --git a/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs b/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs index 7db23b3428b..4d9d22c4988 100644 --- a/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs +++ b/src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs @@ -22,6 +22,8 @@ public void Configuration_should_be_serializable() [Test] public void Basic_CRUD_should_work() { + TestsContext.AssumeSystemTypeIsSerializable(); + Assembly assembly = Assembly.Load("NHibernate.DomainModel"); var cfg = new Configuration(); if (TestConfigurationHelper.hibernateConfigFile != null) diff --git a/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs b/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs index adfc2715e08..d9b94d355de 100644 --- a/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs +++ b/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs @@ -46,9 +46,11 @@ public void CompleteConfiguration() .Using() .AutoQuoteKeywords() .EnableLogFormattedSql() +#if NETFX .BatchingQueries .Through() .Each(15) +#endif .Connected .Through() .By() @@ -80,8 +82,10 @@ public void CompleteConfiguration() Assert.That(cfg.Properties[Environment.Dialect], Is.EqualTo(typeof(MsSql2000Dialect).AssemblyQualifiedName)); Assert.That(cfg.Properties[Environment.Hbm2ddlKeyWords], Is.EqualTo("auto-quote")); Assert.That(cfg.Properties[Environment.FormatSql], Is.EqualTo("true")); +#if NETFX Assert.That(cfg.Properties[Environment.BatchStrategy], Is.EqualTo(typeof(SqlClientBatchingBatcherFactory).AssemblyQualifiedName)); Assert.That(cfg.Properties[Environment.BatchSize], Is.EqualTo("15")); +#endif Assert.That(cfg.Properties[Environment.ConnectionProvider], Is.EqualTo(typeof(DebugConnectionProvider).AssemblyQualifiedName)); Assert.That(cfg.Properties[Environment.ConnectionDriver], Is.EqualTo(typeof(SqlClientDriver).AssemblyQualifiedName)); Assert.That(cfg.Properties[Environment.ReleaseConnections], Is.EqualTo(ConnectionReleaseModeParser.ToString(ConnectionReleaseMode.AfterTransaction))); diff --git a/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs b/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs index cc464aafafa..f422035fd85 100644 --- a/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs +++ b/src/NHibernate.Test/CfgTest/Loquacious/LambdaConfigurationFixture.cs @@ -46,7 +46,9 @@ public void FullConfiguration() { db.Dialect(); db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote; +#if NETFX db.Batcher(); +#endif db.BatchSize = 15; db.ConnectionProvider(); db.Driver(); @@ -82,8 +84,10 @@ public void FullConfiguration() Assert.That(configure.Properties[Environment.Dialect], Is.EqualTo(typeof(MsSql2000Dialect).AssemblyQualifiedName)); Assert.That(configure.Properties[Environment.Hbm2ddlKeyWords], Is.EqualTo("auto-quote")); +#if NETFX Assert.That(configure.Properties[Environment.BatchStrategy], Is.EqualTo(typeof(SqlClientBatchingBatcherFactory).AssemblyQualifiedName)); +#endif Assert.That(configure.Properties[Environment.BatchSize], Is.EqualTo("15")); Assert.That(configure.Properties[Environment.ConnectionProvider], Is.EqualTo(typeof(DebugConnectionProvider).AssemblyQualifiedName)); @@ -104,4 +108,4 @@ public void FullConfiguration() Assert.That(configure.Properties[Environment.LinqToHqlGeneratorsRegistry], Is.EqualTo(typeof(DefaultLinqToHqlGeneratorsRegistry).AssemblyQualifiedName)); } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs b/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs index 47c5bb86c5a..f44bc304e72 100644 --- a/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs +++ b/src/NHibernate.Test/ConnectionStringTest/NamedConnectionStringFixture.cs @@ -35,6 +35,8 @@ public void ConnectionStringInSettingsOverrideNamedConnectionSTring() [Test] public void CanGetNamedConnectionStringFromConfiguration() { + Assume.That(TestsContext.ExecutingWithVsTest, Is.False); + Dictionary settings = new Dictionary(); settings.Add(Environment.ConnectionStringName, "DummyConnectionString"); MockConnectionProvider cp = new MockConnectionProvider(); diff --git a/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs b/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs index e2c1b6af8a1..2b94d4c87ae 100644 --- a/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs +++ b/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs @@ -46,6 +46,8 @@ protected override void Done() [Test] public void SerializationOnAfterStatementAggressiveRelease() { + TestsContext.AssumeSystemTypeIsSerializable(); + Prepare(); ISession s = GetSessionUnderTest(); Silly silly = new Silly("silly"); @@ -67,6 +69,8 @@ public void SerializationOnAfterStatementAggressiveRelease() [Test] public void SerializationFailsOnAfterStatementAggressiveReleaseWithOpenResources() { + TestsContext.AssumeSystemTypeIsSerializable(); + Prepare(); ISession s = GetSessionUnderTest(); @@ -246,4 +250,4 @@ public void ConnectionMaintanenceDuringFlush() Done(); } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs b/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs index 6b94481275b..0be50bf9cb6 100644 --- a/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs +++ b/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs @@ -464,6 +464,8 @@ public void CloningCriteria_AddCount_RemoveOrdering() [Test] public void DetachedCriteriaTest() { + TestsContext.AssumeSystemTypeIsSerializable(); + DetachedCriteria dc = DetachedCriteria.For(typeof(Student)) .Add(Property.ForName("Name").Eq("Gavin King")) .AddOrder(Order.Asc("StudentNumber")) @@ -3051,4 +3053,4 @@ public void CanSetLockModeOnDetachedCriteria() } } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/Criteria/DetachedCriteriaSerializable.cs b/src/NHibernate.Test/Criteria/DetachedCriteriaSerializable.cs index 9dff8ab8bbd..ac84d7e364b 100644 --- a/src/NHibernate.Test/Criteria/DetachedCriteriaSerializable.cs +++ b/src/NHibernate.Test/Criteria/DetachedCriteriaSerializable.cs @@ -54,6 +54,8 @@ public void AllEmbeddedResultTransformersAreSerializable() [Test] public void DetachedCriteriaItSelf() { + TestsContext.AssumeSystemTypeIsSerializable(); + DetachedCriteria dc = DetachedCriteria.For(typeof(Student)) .Add(Expression.Eq("Name", "Gavin King")); SerializeAndList(dc); @@ -183,6 +185,8 @@ public void Junctions() [Test] public void SubqueriesExpressions() { + TestsContext.AssumeSystemTypeIsSerializable(); + DetachedCriteria dc = DetachedCriteria.For(typeof(Student)) .Add(Expression.Eq("Name", "Gavin King")); ICriterion c = Subqueries.Eq("Gavin King", dc); @@ -281,27 +285,41 @@ public void SQLProjection() } [Test] - public void ResultTransformes() + public void ResultTransformesAreSerializable() { IResultTransformer rt = new RootEntityResultTransformer(); NHAssert.IsSerializable(rt); - rt = new AliasToBeanConstructorResultTransformer(typeof(StudentDTO).GetConstructor(System.Type.EmptyTypes)); + rt = new DistinctRootEntityResultTransformer(); NHAssert.IsSerializable(rt); - rt = new AliasToBeanResultTransformer(typeof(StudentDTO)); + rt = new PassThroughResultTransformer(); NHAssert.IsSerializable(rt); + } - rt = new DistinctRootEntityResultTransformer(); + [Test] + public void AliasToBeanConstructorResultTransformerIsSerializable() + { + TestsContext.AssumeSystemTypeIsSerializable(); + + var rt = new AliasToBeanConstructorResultTransformer(typeof(StudentDTO).GetConstructor(System.Type.EmptyTypes)); NHAssert.IsSerializable(rt); + } - rt = new PassThroughResultTransformer(); + [Test] + public void AliasToBeanResultTransformerIsSerializable() + { + TestsContext.AssumeSystemTypeIsSerializable(); + + var rt = new AliasToBeanResultTransformer(typeof(StudentDTO)); NHAssert.IsSerializable(rt); } [Test] public void ExecutableCriteria() { + TestsContext.AssumeSystemTypeIsSerializable(); + // All query below don't have sense, are only to test if all needed classes are serializable // Basic criterion diff --git a/src/NHibernate.Test/DriverTest/DbProviderFactoryDriveConnectionCommandProviderTest.cs b/src/NHibernate.Test/DriverTest/DbProviderFactoryDriveConnectionCommandProviderTest.cs index 16404a6ea6c..54d672de340 100644 --- a/src/NHibernate.Test/DriverTest/DbProviderFactoryDriveConnectionCommandProviderTest.cs +++ b/src/NHibernate.Test/DriverTest/DbProviderFactoryDriveConnectionCommandProviderTest.cs @@ -1,3 +1,4 @@ +#if NETFX using System; using System.Data.Common; using NHibernate.Driver; @@ -37,3 +38,4 @@ public void WhenCreatedWithDbFactoryThenCanReturnCommand() } } } +#endif diff --git a/src/NHibernate.Test/DriverTest/ReflectionBasedDriverTest.cs b/src/NHibernate.Test/DriverTest/ReflectionBasedDriverTest.cs index 17e8c62d6f7..89a017a1b25 100644 --- a/src/NHibernate.Test/DriverTest/ReflectionBasedDriverTest.cs +++ b/src/NHibernate.Test/DriverTest/ReflectionBasedDriverTest.cs @@ -33,13 +33,20 @@ public override string NamedPrefix get { throw new NotImplementedException(); } } } + private class MyDriverWithNoDbProviderFactory : ReflectionBasedDriver { - public MyDriverWithNoDbProviderFactory(): - base(null, - "System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", - "System.Data.OracleClient.OracleConnection", - "System.Data.OracleClient.OracleCommand") { } + public MyDriverWithNoDbProviderFactory() : base( + null, +#if NETFX + "System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", +#else + "System.Data.OracleClient", +#endif + "System.Data.OracleClient.OracleConnection", + "System.Data.OracleClient.OracleCommand") + { + } public override bool UseNamedPrefixInSql { @@ -57,6 +64,7 @@ public override string NamedPrefix } } +#if NETFX [Test] public void WhenCreatedWithGoodDbProviderThenNotThrows() { @@ -88,6 +96,7 @@ public void WhenCreatedWithDbFactoryThenCanReturnCommand() Assert.That(command, Is.Not.Null); } } +#endif [Test] public void WhenCreatedWithNoDbProviderThenNotThrows() diff --git a/src/NHibernate.Test/DynamicProxyTests/InterfaceProxySerializationTests/ProxyFixture.cs b/src/NHibernate.Test/DynamicProxyTests/InterfaceProxySerializationTests/ProxyFixture.cs index d9b5badd6d9..04053dd9e03 100644 --- a/src/NHibernate.Test/DynamicProxyTests/InterfaceProxySerializationTests/ProxyFixture.cs +++ b/src/NHibernate.Test/DynamicProxyTests/InterfaceProxySerializationTests/ProxyFixture.cs @@ -95,6 +95,8 @@ public void Proxy() [Test] public void ProxySerialize() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); IMyProxy ap = new MyProxyImpl {Id = 1, Name = "first proxy"}; s.Save(ap); @@ -126,6 +128,8 @@ public void ProxySerialize() [Test] public void SerializeNotFoundProxy() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); // this does not actually exists in db var notThere = (IMyProxy) s.Load(typeof (MyProxyImpl), 5); @@ -139,4 +143,4 @@ public void SerializeNotFoundProxy() s.Close(); } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorTests.cs b/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorTests.cs index 70d020796af..a8bc63ab416 100644 --- a/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorTests.cs +++ b/src/NHibernate.Test/DynamicProxyTests/LazyFieldInterceptorTests.cs @@ -29,16 +29,17 @@ public void LazyFieldInterceptorMarkedAsSerializable() [Test] public void LazyFieldInterceptorIsBinarySerializable() { + TestsContext.AssumeSystemTypeIsSerializable(); + var pf = new DefaultProxyFactory(); var propertyInfo = typeof(MyClass).GetProperty("Id"); pf.PostInstantiate("MyClass", typeof(MyClass), new HashSet(), propertyInfo.GetGetMethod(), propertyInfo.GetSetMethod(), null); var fieldInterceptionProxy = (IFieldInterceptorAccessor)pf.GetFieldInterceptionProxy(new MyClass()); fieldInterceptionProxy.FieldInterceptor = new DefaultFieldInterceptor(null, null, null, "MyClass", typeof(MyClass)); - Assert.That(fieldInterceptionProxy, Is.BinarySerializable); + NHAssert.IsSerializable(fieldInterceptionProxy); } - [Test] public void DefaultDynamicLazyFieldInterceptorUnWrapsTIEExceptions() { diff --git a/src/NHibernate.Test/Legacy/FooBarTest.cs b/src/NHibernate.Test/Legacy/FooBarTest.cs index 335b2cd4468..0a05c46e884 100644 --- a/src/NHibernate.Test/Legacy/FooBarTest.cs +++ b/src/NHibernate.Test/Legacy/FooBarTest.cs @@ -2632,6 +2632,8 @@ public void NewFlushing() [Test] public void PersistCollections() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); ITransaction txn = s.BeginTransaction(); IEnumerator enumer = s.CreateQuery("select count(*) from b in class Bar").Enumerable().GetEnumerator(); @@ -4642,6 +4644,8 @@ public void SaveDelete() [Test] public void ProxyArray() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); GlarchProxy g = new Glarch(); Glarch g1 = new Glarch(); diff --git a/src/NHibernate.Test/Legacy/MasterDetailTest.cs b/src/NHibernate.Test/Legacy/MasterDetailTest.cs index 9ffc61a4520..6d3e7b4e067 100644 --- a/src/NHibernate.Test/Legacy/MasterDetailTest.cs +++ b/src/NHibernate.Test/Legacy/MasterDetailTest.cs @@ -639,6 +639,8 @@ public void NamedQuery() [Test] public void Serialization() { + TestsContext.AssumeSystemTypeIsSerializable(); + ISession s = OpenSession(); Master m = new Master(); Detail d1 = new Detail(); diff --git a/src/NHibernate.Test/Linq/NorthwindDbCreator.cs b/src/NHibernate.Test/Linq/NorthwindDbCreator.cs index bb3ddfcc91c..dbb34f93bd2 100644 --- a/src/NHibernate.Test/Linq/NorthwindDbCreator.cs +++ b/src/NHibernate.Test/Linq/NorthwindDbCreator.cs @@ -560,6 +560,20 @@ static IEnumerable CreateProducts(IStatelessSession session, IDictionar static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName) { var orders = new List(); + CreateOrders1(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + CreateOrders2(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + CreateOrders3(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + CreateOrders4(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + CreateOrders5(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + CreateOrders6(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + CreateOrders7(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + CreateOrders8(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + CreateOrders9(session, customersByCompanyName, employeesByLastName, shippersByCompanyName, orders); + return orders; + } + + static void CreateOrders1(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { var order = new Order { OrderId = 10248, Customer = customersByCompanyName["Vins et alcools Chevalier"], Employee = employeesByLastName["Buchanan"], OrderDate = DateTime.Parse("Jul 4 1996 12:00AM"), RequiredDate = DateTime.Parse("Aug 1 1996 12:00AM"), ShippingDate = DateTime.Parse("Jul 16 1996 12:00AM"), Shipper = shippersByCompanyName["Federal Shipping"], Freight = 32.38M, ShippedTo = "Vins et alcools Chevalier", ShippingAddress = new Address("59 rue de l'Abbaye", "Reims", "null", "51100", "France", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10249, Customer = customersByCompanyName["Toms Spezialitäten"], Employee = employeesByLastName["Suyama"], OrderDate = DateTime.Parse("Jul 5 1996 12:00AM"), RequiredDate = DateTime.Parse("Aug 16 1996 12:00AM"), ShippingDate = DateTime.Parse("Jul 10 1996 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 11.61M, ShippedTo = "Toms Spezialitäten", ShippingAddress = new Address("Luisenstr. 48", "Münster", "null", "44087", "Germany", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10250, Customer = customersByCompanyName["Hanari Carnes"], Employee = employeesByLastName["Peacock"], OrderDate = DateTime.Parse("Jul 8 1996 12:00AM"), RequiredDate = DateTime.Parse("Aug 5 1996 12:00AM"), ShippingDate = DateTime.Parse("Jul 12 1996 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 65.83M, ShippedTo = "Hanari Carnes", ShippingAddress = new Address("Rua do Paço, 67", "Rio de Janeiro", "RJ", "05454-876", "Brazil", null, null) }; session.Insert(order); orders.Add(order); @@ -661,7 +675,11 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { + var order = new Order { OrderId = 10349, Customer = customersByCompanyName["Split Rail Beer & Ale"], Employee = employeesByLastName["King"], OrderDate = DateTime.Parse("Nov 8 1996 12:00AM"), RequiredDate = DateTime.Parse("Dec 6 1996 12:00AM"), ShippingDate = DateTime.Parse("Nov 15 1996 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 8.63M, ShippedTo = "Split Rail Beer & Ale", ShippingAddress = new Address("P.O. Box 555", "Lander", "WY", "82520", "USA", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10350, Customer = customersByCompanyName["La maison d'Asie"], Employee = employeesByLastName["Suyama"], OrderDate = DateTime.Parse("Nov 11 1996 12:00AM"), RequiredDate = DateTime.Parse("Dec 9 1996 12:00AM"), ShippingDate = DateTime.Parse("Dec 3 1996 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 64.19M, ShippedTo = "La maison d'Asie", ShippingAddress = new Address("1 rue Alsace-Lorraine", "Toulouse", "null", "31000", "France", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10351, Customer = customersByCompanyName["Ernst Handel"], Employee = employeesByLastName["Davolio"], OrderDate = DateTime.Parse("Nov 11 1996 12:00AM"), RequiredDate = DateTime.Parse("Dec 9 1996 12:00AM"), ShippingDate = DateTime.Parse("Nov 20 1996 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 162.33M, ShippedTo = "Ernst Handel", ShippingAddress = new Address("Kirchgasse 6", "Graz", "null", "8010", "Austria", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10352, Customer = customersByCompanyName["Furia Bacalhau e Frutos do Mar"], Employee = employeesByLastName["Leverling"], OrderDate = DateTime.Parse("Nov 12 1996 12:00AM"), RequiredDate = DateTime.Parse("Nov 26 1996 12:00AM"), ShippingDate = DateTime.Parse("Nov 18 1996 12:00AM"), Shipper = shippersByCompanyName["Federal Shipping"], Freight = 1.30M, ShippedTo = "Furia Bacalhau e Frutos do Mar", ShippingAddress = new Address("Jardim das rosas n. 32", "Lisboa", "null", "1675", "Portugal", null, null) }; session.Insert(order); orders.Add(order); @@ -762,7 +780,11 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { + var order = new Order { OrderId = 10450, Customer = customersByCompanyName["Victuailles en stock"], Employee = employeesByLastName["Callahan"], OrderDate = DateTime.Parse("Feb 19 1997 12:00AM"), RequiredDate = DateTime.Parse("Mar 19 1997 12:00AM"), ShippingDate = DateTime.Parse("Mar 11 1997 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 7.23M, ShippedTo = "Victuailles en stock", ShippingAddress = new Address("2, rue du Commerce", "Lyon", "null", "69004", "France", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10451, Customer = customersByCompanyName["QUICK-Stop"], Employee = employeesByLastName["Peacock"], OrderDate = DateTime.Parse("Feb 19 1997 12:00AM"), RequiredDate = DateTime.Parse("Mar 5 1997 12:00AM"), ShippingDate = DateTime.Parse("Mar 12 1997 12:00AM"), Shipper = shippersByCompanyName["Federal Shipping"], Freight = 189.09M, ShippedTo = "QUICK-Stop", ShippingAddress = new Address("Taucherstraße 10", "Cunewalde", "null", "01307", "Germany", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10452, Customer = customersByCompanyName["Save-a-lot Markets"], Employee = employeesByLastName["Callahan"], OrderDate = DateTime.Parse("Feb 20 1997 12:00AM"), RequiredDate = DateTime.Parse("Mar 20 1997 12:00AM"), ShippingDate = DateTime.Parse("Feb 26 1997 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 140.26M, ShippedTo = "Save-a-lot Markets", ShippingAddress = new Address("187 Suffolk Ln.", "Boise", "ID", "83720", "USA", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10453, Customer = customersByCompanyName["Around the Horn"], Employee = employeesByLastName["Davolio"], OrderDate = DateTime.Parse("Feb 21 1997 12:00AM"), RequiredDate = DateTime.Parse("Mar 21 1997 12:00AM"), ShippingDate = DateTime.Parse("Feb 26 1997 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 25.36M, ShippedTo = "Around the Horn", ShippingAddress = new Address("Brook Farm Stratford St. Mary", "Colchester", "Essex", "CO7 6JX", "UK", null, null) }; session.Insert(order); orders.Add(order); @@ -864,7 +886,11 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { + var order = new Order { OrderId = 10552, Customer = customersByCompanyName["HILARION-Abastos"], Employee = employeesByLastName["Fuller"], OrderDate = DateTime.Parse("May 29 1997 12:00AM"), RequiredDate = DateTime.Parse("Jun 26 1997 12:00AM"), ShippingDate = DateTime.Parse("Jun 5 1997 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 83.22M, ShippedTo = "HILARION-Abastos", ShippingAddress = new Address("Carrera 22 con Ave. Carlos Soublette #8-35", "San Cristóbal", "Táchira", "5022", "Venezuela", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10553, Customer = customersByCompanyName["Wartian Herkku"], Employee = employeesByLastName["Fuller"], OrderDate = DateTime.Parse("May 30 1997 12:00AM"), RequiredDate = DateTime.Parse("Jun 27 1997 12:00AM"), ShippingDate = DateTime.Parse("Jun 3 1997 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 149.49M, ShippedTo = "Wartian Herkku", ShippingAddress = new Address("Torikatu 38", "Oulu", "null", "90110", "Finland", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10554, Customer = customersByCompanyName["Ottilies Käseladen"], Employee = employeesByLastName["Peacock"], OrderDate = DateTime.Parse("May 30 1997 12:00AM"), RequiredDate = DateTime.Parse("Jun 27 1997 12:00AM"), ShippingDate = DateTime.Parse("Jun 5 1997 12:00AM"), Shipper = shippersByCompanyName["Federal Shipping"], Freight = 120.97M, ShippedTo = "Ottilies Käseladen", ShippingAddress = new Address("Mehrheimerstr. 369", "Köln", "null", "50739", "Germany", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10555, Customer = customersByCompanyName["Save-a-lot Markets"], Employee = employeesByLastName["Suyama"], OrderDate = DateTime.Parse("Jun 2 1997 12:00AM"), RequiredDate = DateTime.Parse("Jun 30 1997 12:00AM"), ShippingDate = DateTime.Parse("Jun 4 1997 12:00AM"), Shipper = shippersByCompanyName["Federal Shipping"], Freight = 252.49M, ShippedTo = "Save-a-lot Markets", ShippingAddress = new Address("187 Suffolk Ln.", "Boise", "ID", "83720", "USA", null, null) }; session.Insert(order); orders.Add(order); @@ -965,7 +991,11 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { + var order = new Order { OrderId = 10653, Customer = customersByCompanyName["Frankenversand"], Employee = employeesByLastName["Davolio"], OrderDate = DateTime.Parse("Sep 2 1997 12:00AM"), RequiredDate = DateTime.Parse("Sep 30 1997 12:00AM"), ShippingDate = DateTime.Parse("Sep 19 1997 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 93.25M, ShippedTo = "Frankenversand", ShippingAddress = new Address("Berliner Platz 43", "München", "null", "80805", "Germany", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10654, Customer = customersByCompanyName["Berglunds snabbköp"], Employee = employeesByLastName["Buchanan"], OrderDate = DateTime.Parse("Sep 2 1997 12:00AM"), RequiredDate = DateTime.Parse("Sep 30 1997 12:00AM"), ShippingDate = DateTime.Parse("Sep 11 1997 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 55.26M, ShippedTo = "Berglunds snabbköp", ShippingAddress = new Address("Berguvsvägen 8", "Luleå", "null", "S-958 22", "Sweden", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10655, Customer = customersByCompanyName["Reggiani Caseifici"], Employee = employeesByLastName["Davolio"], OrderDate = DateTime.Parse("Sep 3 1997 12:00AM"), RequiredDate = DateTime.Parse("Oct 1 1997 12:00AM"), ShippingDate = DateTime.Parse("Sep 11 1997 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 4.41M, ShippedTo = "Reggiani Caseifici", ShippingAddress = new Address("Strada Provinciale 124", "Reggio Emilia", "null", "42100", "Italy", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10656, Customer = customersByCompanyName["Great Lakes Food Market"], Employee = employeesByLastName["Suyama"], OrderDate = DateTime.Parse("Sep 4 1997 12:00AM"), RequiredDate = DateTime.Parse("Oct 2 1997 12:00AM"), ShippingDate = DateTime.Parse("Sep 10 1997 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 57.15M, ShippedTo = "Great Lakes Food Market", ShippingAddress = new Address("2732 Baker Blvd.", "Eugene", "OR", "97403", "USA", null, null) }; session.Insert(order); orders.Add(order); @@ -1066,7 +1096,11 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { + var order = new Order { OrderId = 10754, Customer = customersByCompanyName["Magazzini Alimentari Riuniti"], Employee = employeesByLastName["Suyama"], OrderDate = DateTime.Parse("Nov 25 1997 12:00AM"), RequiredDate = DateTime.Parse("Dec 23 1997 12:00AM"), ShippingDate = DateTime.Parse("Nov 27 1997 12:00AM"), Shipper = shippersByCompanyName["Federal Shipping"], Freight = 2.38M, ShippedTo = "Magazzini Alimentari Riuniti", ShippingAddress = new Address("Via Ludovico il Moro 22", "Bergamo", "null", "24100", "Italy", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10755, Customer = customersByCompanyName["Bon app'"], Employee = employeesByLastName["Peacock"], OrderDate = DateTime.Parse("Nov 26 1997 12:00AM"), RequiredDate = DateTime.Parse("Dec 24 1997 12:00AM"), ShippingDate = DateTime.Parse("Nov 28 1997 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 16.71M, ShippedTo = "Bon app'", ShippingAddress = new Address("12, rue des Bouchers", "Marseille", "null", "13008", "France", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10756, Customer = customersByCompanyName["Split Rail Beer & Ale"], Employee = employeesByLastName["Callahan"], OrderDate = DateTime.Parse("Nov 27 1997 12:00AM"), RequiredDate = DateTime.Parse("Dec 25 1997 12:00AM"), ShippingDate = DateTime.Parse("Dec 2 1997 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 73.21M, ShippedTo = "Split Rail Beer & Ale", ShippingAddress = new Address("P.O. Box 555", "Lander", "WY", "82520", "USA", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10757, Customer = customersByCompanyName["Save-a-lot Markets"], Employee = employeesByLastName["Suyama"], OrderDate = DateTime.Parse("Nov 27 1997 12:00AM"), RequiredDate = DateTime.Parse("Dec 25 1997 12:00AM"), ShippingDate = DateTime.Parse("Dec 15 1997 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 8.19M, ShippedTo = "Save-a-lot Markets", ShippingAddress = new Address("187 Suffolk Ln.", "Boise", "ID", "83720", "USA", null, null) }; session.Insert(order); orders.Add(order); @@ -1166,7 +1200,11 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { + var order = new Order { OrderId = 10854, Customer = customersByCompanyName["Ernst Handel"], Employee = employeesByLastName["Leverling"], OrderDate = DateTime.Parse("Jan 27 1998 12:00AM"), RequiredDate = DateTime.Parse("Feb 24 1998 12:00AM"), ShippingDate = DateTime.Parse("Feb 5 1998 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 100.22M, ShippedTo = "Ernst Handel", ShippingAddress = new Address("Kirchgasse 6", "Graz", "null", "8010", "Austria", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10855, Customer = customersByCompanyName["Old World Delicatessen"], Employee = employeesByLastName["Leverling"], OrderDate = DateTime.Parse("Jan 27 1998 12:00AM"), RequiredDate = DateTime.Parse("Feb 24 1998 12:00AM"), ShippingDate = DateTime.Parse("Feb 4 1998 12:00AM"), Shipper = shippersByCompanyName["Speedy Express"], Freight = 170.97M, ShippedTo = "Old World Delicatessen", ShippingAddress = new Address("2743 Bering St.", "Anchorage", "AK", "99508", "USA", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10856, Customer = customersByCompanyName["Antonio Moreno Taquería"], Employee = employeesByLastName["Leverling"], OrderDate = DateTime.Parse("Jan 28 1998 12:00AM"), RequiredDate = DateTime.Parse("Feb 25 1998 12:00AM"), ShippingDate = DateTime.Parse("Feb 10 1998 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 58.43M, ShippedTo = "Antonio Moreno Taquería", ShippingAddress = new Address("Mataderos 2312", "México D.F.", "null", "05023", "Mexico", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10857, Customer = customersByCompanyName["Berglunds snabbköp"], Employee = employeesByLastName["Callahan"], OrderDate = DateTime.Parse("Jan 28 1998 12:00AM"), RequiredDate = DateTime.Parse("Feb 25 1998 12:00AM"), ShippingDate = DateTime.Parse("Feb 6 1998 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 188.85M, ShippedTo = "Berglunds snabbköp", ShippingAddress = new Address("Berguvsvägen 8", "Luleå", "null", "S-958 22", "Sweden", null, null) }; session.Insert(order); orders.Add(order); @@ -1267,7 +1305,11 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { + var order = new Order { OrderId = 10955, Customer = customersByCompanyName["Folk och fä HB"], Employee = employeesByLastName["Callahan"], OrderDate = DateTime.Parse("Mar 17 1998 12:00AM"), RequiredDate = DateTime.Parse("Apr 14 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 20 1998 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 3.26M, ShippedTo = "Folk och fä HB", ShippingAddress = new Address("Åkergatan 24", "Bräcke", "null", "S-844 67", "Sweden", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10956, Customer = customersByCompanyName["Blauer See Delikatessen"], Employee = employeesByLastName["Suyama"], OrderDate = DateTime.Parse("Mar 17 1998 12:00AM"), RequiredDate = DateTime.Parse("Apr 28 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 20 1998 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 44.65M, ShippedTo = "Blauer See Delikatessen", ShippingAddress = new Address("Forsterstr. 57", "Mannheim", "null", "68306", "Germany", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10957, Customer = customersByCompanyName["HILARION-Abastos"], Employee = employeesByLastName["Callahan"], OrderDate = DateTime.Parse("Mar 18 1998 12:00AM"), RequiredDate = DateTime.Parse("Apr 15 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 27 1998 12:00AM"), Shipper = shippersByCompanyName["Federal Shipping"], Freight = 105.36M, ShippedTo = "HILARION-Abastos", ShippingAddress = new Address("Carrera 22 con Ave. Carlos Soublette #8-35", "San Cristóbal", "Táchira", "5022", "Venezuela", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 10958, Customer = customersByCompanyName["Océano Atlántico Ltda."], Employee = employeesByLastName["King"], OrderDate = DateTime.Parse("Mar 18 1998 12:00AM"), RequiredDate = DateTime.Parse("Apr 15 1998 12:00AM"), ShippingDate = DateTime.Parse("Mar 27 1998 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 49.56M, ShippedTo = "Océano Atlántico Ltda.", ShippingAddress = new Address("Ing. Gustavo Moncada 8585 Piso 20-A", "Buenos Aires", "null", "1010", "Argentina", null, null) }; session.Insert(order); orders.Add(order); @@ -1368,7 +1410,11 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary customersByCompanyName, IDictionary employeesByLastName, IDictionary shippersByCompanyName, List orders) + { + var order = new Order { OrderId = 11056, Customer = customersByCompanyName["Eastern Connection"], Employee = employeesByLastName["Callahan"], OrderDate = DateTime.Parse("Apr 28 1998 12:00AM"), RequiredDate = DateTime.Parse("May 12 1998 12:00AM"), ShippingDate = DateTime.Parse("May 1 1998 12:00AM"), Shipper = shippersByCompanyName["United Package"], Freight = 278.96M, ShippedTo = "Eastern Connection", ShippingAddress = new Address("35 King George", "London", "null", "WX3 6FW", "UK", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 11057, Customer = customersByCompanyName["North/South"], Employee = employeesByLastName["Leverling"], OrderDate = DateTime.Parse("Apr 29 1998 12:00AM"), RequiredDate = DateTime.Parse("May 27 1998 12:00AM"), ShippingDate = DateTime.Parse("May 1 1998 12:00AM"), Shipper = shippersByCompanyName["Federal Shipping"], Freight = 4.13M, ShippedTo = "North/South", ShippingAddress = new Address("South House 300 Queensbridge", "London", "null", "SW7 1RZ", "UK", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 11058, Customer = customersByCompanyName["Blauer See Delikatessen"], Employee = employeesByLastName["Dodsworth"], OrderDate = DateTime.Parse("Apr 29 1998 12:00AM"), RequiredDate = DateTime.Parse("May 27 1998 12:00AM"), ShippingDate = null, Shipper = shippersByCompanyName["Federal Shipping"], Freight = 31.14M, ShippedTo = "Blauer See Delikatessen", ShippingAddress = new Address("Forsterstr. 57", "Mannheim", "null", "68306", "Germany", null, null) }; session.Insert(order); orders.Add(order); order = new Order { OrderId = 11059, Customer = customersByCompanyName["Ricardo Adocicados"], Employee = employeesByLastName["Fuller"], OrderDate = DateTime.Parse("Apr 29 1998 12:00AM"), RequiredDate = DateTime.Parse("Jun 10 1998 12:00AM"), ShippingDate = null, Shipper = shippersByCompanyName["United Package"], Freight = 85.80M, ShippedTo = "Ricardo Adocicados", ShippingAddress = new Address("Av. Copacabana, 267", "Rio de Janeiro", "RJ", "02389-890", "Brazil", null, null) }; session.Insert(order); orders.Add(order); @@ -1390,12 +1436,36 @@ static IEnumerable CreateOrders(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) - { + { + CreateOrderLines1(session, ordersById, productsByName); + CreateOrderLines2(session, ordersById, productsByName); + CreateOrderLines3(session, ordersById, productsByName); + CreateOrderLines4(session, ordersById, productsByName); + CreateOrderLines5(session, ordersById, productsByName); + CreateOrderLines6(session, ordersById, productsByName); + CreateOrderLines7(session, ordersById, productsByName); + CreateOrderLines8(session, ordersById, productsByName); + CreateOrderLines9(session, ordersById, productsByName); + CreateOrderLines10(session, ordersById, productsByName); + CreateOrderLines11(session, ordersById, productsByName); + CreateOrderLines12(session, ordersById, productsByName); + CreateOrderLines13(session, ordersById, productsByName); + CreateOrderLines14(session, ordersById, productsByName); + CreateOrderLines15(session, ordersById, productsByName); + CreateOrderLines16(session, ordersById, productsByName); + CreateOrderLines17(session, ordersById, productsByName); + CreateOrderLines18(session, ordersById, productsByName); + CreateOrderLines19(session, ordersById, productsByName); + CreateOrderLines20(session, ordersById, productsByName); + CreateOrderLines21(session, ordersById, productsByName); + CreateOrderLines22(session, ordersById, productsByName); + } + + static void CreateOrderLines1(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { var orderLine = new OrderLine { Order = ordersById[10248], Product = productsByName["Queso Cabrales"], UnitPrice = 14.00M, Quantity = 12, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10248], Product = productsByName["Singaporean Hokkien Fried Mee"], UnitPrice = 9.80M, Quantity = 10, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10248], Product = productsByName["Mozzarella di Giovanni"], UnitPrice = 34.80M, Quantity = 5, Discount = 0M }; session.Insert(orderLine); @@ -1496,7 +1566,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10284], Product = productsByName["Camembert Pierrot"], UnitPrice = 27.20M, Quantity = 20, Discount = 0.25M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10284], Product = productsByName["Laughing Lumberjack Lager"], UnitPrice = 11.20M, Quantity = 5, Discount = 0.25M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10285], Product = productsByName["Chai"], UnitPrice = 14.40M, Quantity = 45, Discount = 0.2M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10285], Product = productsByName["Boston Crab Meat"], UnitPrice = 14.70M, Quantity = 40, Discount = 0.2M }; session.Insert(orderLine); + } + + static void CreateOrderLines2(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10285], Product = productsByName["Boston Crab Meat"], UnitPrice = 14.70M, Quantity = 40, Discount = 0.2M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10285], Product = productsByName["Perth Pasties"], UnitPrice = 26.20M, Quantity = 36, Discount = 0.2M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10286], Product = productsByName["Steeleye Stout"], UnitPrice = 14.40M, Quantity = 100, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10286], Product = productsByName["Tarte au sucre"], UnitPrice = 39.40M, Quantity = 40, Discount = 0M }; session.Insert(orderLine); @@ -1596,7 +1670,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10324], Product = productsByName["Steeleye Stout"], UnitPrice = 14.40M, Quantity = 70, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10324], Product = productsByName["Spegesild"], UnitPrice = 9.60M, Quantity = 30, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10324], Product = productsByName["Raclette Courdavault"], UnitPrice = 44.00M, Quantity = 40, Discount = 0.15M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10324], Product = productsByName["Vegie-spread"], UnitPrice = 35.10M, Quantity = 80, Discount = 0.15M }; session.Insert(orderLine); + } + + static void CreateOrderLines3(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10324], Product = productsByName["Vegie-spread"], UnitPrice = 35.10M, Quantity = 80, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10325], Product = productsByName["Grandma's Boysenberry Spread"], UnitPrice = 20.00M, Quantity = 6, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10325], Product = productsByName["Konbu"], UnitPrice = 4.80M, Quantity = 12, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10325], Product = productsByName["Tofu"], UnitPrice = 18.60M, Quantity = 9, Discount = 0M }; session.Insert(orderLine); @@ -1697,7 +1775,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10360], Product = productsByName["Rössle Sauerkraut"], UnitPrice = 36.40M, Quantity = 30, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10360], Product = productsByName["Thüringer Rostbratwurst"], UnitPrice = 99.00M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10360], Product = productsByName["Côte de Blaye"], UnitPrice = 210.80M, Quantity = 10, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10360], Product = productsByName["Maxilaku"], UnitPrice = 16.00M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines4(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10360], Product = productsByName["Maxilaku"], UnitPrice = 16.00M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10360], Product = productsByName["Tourtière"], UnitPrice = 5.90M, Quantity = 28, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10361], Product = productsByName["Chartreuse verte"], UnitPrice = 14.40M, Quantity = 54, Discount = 0.1M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10361], Product = productsByName["Camembert Pierrot"], UnitPrice = 27.20M, Quantity = 55, Discount = 0.1M }; session.Insert(orderLine); @@ -1798,7 +1880,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10398], Product = productsByName["Steeleye Stout"], UnitPrice = 14.40M, Quantity = 30, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10398], Product = productsByName["Pâté chinois"], UnitPrice = 19.20M, Quantity = 120, Discount = 0.1M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10399], Product = productsByName["Scottish Longbreads"], UnitPrice = 10.00M, Quantity = 60, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10399], Product = productsByName["Flotemysost"], UnitPrice = 17.20M, Quantity = 30, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines5(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10399], Product = productsByName["Flotemysost"], UnitPrice = 17.20M, Quantity = 30, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10399], Product = productsByName["Lakkalikööri"], UnitPrice = 14.40M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10399], Product = productsByName["Original Frankfurter grüne Soße"], UnitPrice = 10.40M, Quantity = 14, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10400], Product = productsByName["Thüringer Rostbratwurst"], UnitPrice = 99.00M, Quantity = 21, Discount = 0M }; session.Insert(orderLine); @@ -1898,7 +1984,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10436], Product = productsByName["Rhönbräu Klosterbier"], UnitPrice = 6.20M, Quantity = 24, Discount = 0.1M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10437], Product = productsByName["Perth Pasties"], UnitPrice = 26.20M, Quantity = 15, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10438], Product = productsByName["Teatime Chocolate Biscuits"], UnitPrice = 7.30M, Quantity = 15, Discount = 0.2M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10438], Product = productsByName["Sasquatch Ale"], UnitPrice = 11.20M, Quantity = 20, Discount = 0.2M }; session.Insert(orderLine); + } + + static void CreateOrderLines6(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10438], Product = productsByName["Sasquatch Ale"], UnitPrice = 11.20M, Quantity = 20, Discount = 0.2M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10438], Product = productsByName["Ravioli Angelo"], UnitPrice = 15.60M, Quantity = 15, Discount = 0.2M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10439], Product = productsByName["Queso Manchego La Pastora"], UnitPrice = 30.40M, Quantity = 15, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10439], Product = productsByName["Pavlova"], UnitPrice = 13.90M, Quantity = 16, Discount = 0M }; session.Insert(orderLine); @@ -1998,7 +2088,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10473], Product = productsByName["Flotemysost"], UnitPrice = 17.20M, Quantity = 12, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10474], Product = productsByName["Tofu"], UnitPrice = 18.60M, Quantity = 12, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10474], Product = productsByName["Rössle Sauerkraut"], UnitPrice = 36.40M, Quantity = 18, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10474], Product = productsByName["Boston Crab Meat"], UnitPrice = 14.70M, Quantity = 21, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines7(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10474], Product = productsByName["Boston Crab Meat"], UnitPrice = 14.70M, Quantity = 21, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10474], Product = productsByName["Rhönbräu Klosterbier"], UnitPrice = 6.20M, Quantity = 10, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10475], Product = productsByName["Gorgonzola Telino"], UnitPrice = 10.00M, Quantity = 35, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10475], Product = productsByName["Louisiana Hot Spiced Okra"], UnitPrice = 13.60M, Quantity = 60, Discount = 0.15M }; session.Insert(orderLine); @@ -2099,7 +2193,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10514], Product = productsByName["Rhönbräu Klosterbier"], UnitPrice = 7.75M, Quantity = 50, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10515], Product = productsByName["Mishi Kobe Niku"], UnitPrice = 97.00M, Quantity = 16, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10515], Product = productsByName["Pavlova"], UnitPrice = 17.45M, Quantity = 50, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10515], Product = productsByName["Schoggi Schokolade"], UnitPrice = 43.90M, Quantity = 120, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines8(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10515], Product = productsByName["Schoggi Schokolade"], UnitPrice = 43.90M, Quantity = 120, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10515], Product = productsByName["Geitost"], UnitPrice = 2.50M, Quantity = 16, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10515], Product = productsByName["Camembert Pierrot"], UnitPrice = 34.00M, Quantity = 84, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10516], Product = productsByName["Carnarvon Tigers"], UnitPrice = 62.50M, Quantity = 25, Discount = 0.1M }; session.Insert(orderLine); @@ -2200,7 +2298,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10548], Product = productsByName["Jack's New England Clam Chowder"], UnitPrice = 9.65M, Quantity = 14, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10549], Product = productsByName["Gorgonzola Telino"], UnitPrice = 12.50M, Quantity = 55, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10549], Product = productsByName["Rogede sild"], UnitPrice = 9.50M, Quantity = 100, Discount = 0.15M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10549], Product = productsByName["Manjimup Dried Apples"], UnitPrice = 53.00M, Quantity = 48, Discount = 0.15M }; session.Insert(orderLine); + } + + static void CreateOrderLines9(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10549], Product = productsByName["Manjimup Dried Apples"], UnitPrice = 53.00M, Quantity = 48, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10550], Product = productsByName["Alice Mutton"], UnitPrice = 39.00M, Quantity = 8, Discount = 0.1M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10550], Product = productsByName["Teatime Chocolate Biscuits"], UnitPrice = 9.20M, Quantity = 10, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10550], Product = productsByName["Sir Rodney's Scones"], UnitPrice = 10.00M, Quantity = 6, Discount = 0.1M }; session.Insert(orderLine); @@ -2301,7 +2403,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10587], Product = productsByName["Steeleye Stout"], UnitPrice = 18.00M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10587], Product = productsByName["Original Frankfurter grüne Soße"], UnitPrice = 13.00M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10588], Product = productsByName["Carnarvon Tigers"], UnitPrice = 62.50M, Quantity = 40, Discount = 0.2M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10588], Product = productsByName["Singaporean Hokkien Fried Mee"], UnitPrice = 14.00M, Quantity = 100, Discount = 0.2M }; session.Insert(orderLine); + } + + static void CreateOrderLines10(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10588], Product = productsByName["Singaporean Hokkien Fried Mee"], UnitPrice = 14.00M, Quantity = 100, Discount = 0.2M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10589], Product = productsByName["Steeleye Stout"], UnitPrice = 18.00M, Quantity = 4, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10590], Product = productsByName["Chai"], UnitPrice = 18.00M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10590], Product = productsByName["Original Frankfurter grüne Soße"], UnitPrice = 13.00M, Quantity = 60, Discount = 0.05M }; session.Insert(orderLine); @@ -2402,7 +2508,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10627], Product = productsByName["Tarte au sucre"], UnitPrice = 49.30M, Quantity = 15, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10627], Product = productsByName["Röd Kaviar"], UnitPrice = 15.00M, Quantity = 35, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10628], Product = productsByName["Chai"], UnitPrice = 18.00M, Quantity = 25, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10629], Product = productsByName["Thüringer Rostbratwurst"], UnitPrice = 123.79M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines11(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10629], Product = productsByName["Thüringer Rostbratwurst"], UnitPrice = 123.79M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10629], Product = productsByName["Wimmers gute Semmelknödel"], UnitPrice = 33.25M, Quantity = 9, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10630], Product = productsByName["Pâté chinois"], UnitPrice = 24.00M, Quantity = 12, Discount = 0.05M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10630], Product = productsByName["Lakkalikööri"], UnitPrice = 18.00M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); @@ -2503,7 +2613,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10668], Product = productsByName["Pâté chinois"], UnitPrice = 24.00M, Quantity = 4, Discount = 0.1M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10668], Product = productsByName["Wimmers gute Semmelknödel"], UnitPrice = 33.25M, Quantity = 15, Discount = 0.1M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10669], Product = productsByName["Inlagd Sill"], UnitPrice = 19.00M, Quantity = 30, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10670], Product = productsByName["Tunnbröd"], UnitPrice = 9.00M, Quantity = 32, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines12(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10670], Product = productsByName["Tunnbröd"], UnitPrice = 9.00M, Quantity = 32, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10670], Product = productsByName["Spegesild"], UnitPrice = 12.00M, Quantity = 60, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10670], Product = productsByName["Laughing Lumberjack Lager"], UnitPrice = 14.00M, Quantity = 25, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10670], Product = productsByName["Röd Kaviar"], UnitPrice = 15.00M, Quantity = 50, Discount = 0M }; session.Insert(orderLine); @@ -2604,7 +2718,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10705], Product = productsByName["Mascarpone Fabioli"], UnitPrice = 32.00M, Quantity = 4, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10706], Product = productsByName["Pavlova"], UnitPrice = 17.45M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10706], Product = productsByName["Ipoh Coffee"], UnitPrice = 46.00M, Quantity = 24, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10706], Product = productsByName["Raclette Courdavault"], UnitPrice = 55.00M, Quantity = 8, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines13(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10706], Product = productsByName["Raclette Courdavault"], UnitPrice = 55.00M, Quantity = 8, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10707], Product = productsByName["Pâté chinois"], UnitPrice = 24.00M, Quantity = 21, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10707], Product = productsByName["Ravioli Angelo"], UnitPrice = 19.50M, Quantity = 40, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10707], Product = productsByName["Outback Lager"], UnitPrice = 15.00M, Quantity = 28, Discount = 0.15M }; session.Insert(orderLine); @@ -2705,7 +2823,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10745], Product = productsByName["Raclette Courdavault"], UnitPrice = 55.00M, Quantity = 45, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10745], Product = productsByName["Mozzarella di Giovanni"], UnitPrice = 34.80M, Quantity = 7, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10746], Product = productsByName["Konbu"], UnitPrice = 6.00M, Quantity = 6, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10746], Product = productsByName["Singaporean Hokkien Fried Mee"], UnitPrice = 14.00M, Quantity = 28, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines14(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10746], Product = productsByName["Singaporean Hokkien Fried Mee"], UnitPrice = 14.00M, Quantity = 28, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10746], Product = productsByName["Tarte au sucre"], UnitPrice = 49.30M, Quantity = 9, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10746], Product = productsByName["Gudbrandsdalsost"], UnitPrice = 36.00M, Quantity = 40, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10747], Product = productsByName["Gorgonzola Telino"], UnitPrice = 12.50M, Quantity = 8, Discount = 0M }; session.Insert(orderLine); @@ -2806,7 +2928,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10785], Product = productsByName["Ikura"], UnitPrice = 31.00M, Quantity = 10, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10785], Product = productsByName["Rhönbräu Klosterbier"], UnitPrice = 7.75M, Quantity = 10, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10786], Product = productsByName["Northwoods Cranberry Sauce"], UnitPrice = 40.00M, Quantity = 30, Discount = 0.2M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10786], Product = productsByName["Nord-Ost Matjeshering"], UnitPrice = 25.89M, Quantity = 15, Discount = 0.2M }; session.Insert(orderLine); + } + + static void CreateOrderLines15(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10786], Product = productsByName["Nord-Ost Matjeshering"], UnitPrice = 25.89M, Quantity = 15, Discount = 0.2M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10786], Product = productsByName["Rhönbräu Klosterbier"], UnitPrice = 7.75M, Quantity = 42, Discount = 0.2M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10787], Product = productsByName["Chang"], UnitPrice = 19.00M, Quantity = 15, Discount = 0.05M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10787], Product = productsByName["Thüringer Rostbratwurst"], UnitPrice = 123.79M, Quantity = 20, Discount = 0.05M }; session.Insert(orderLine); @@ -2907,7 +3033,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10827], Product = productsByName["Ikura"], UnitPrice = 31.00M, Quantity = 15, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10827], Product = productsByName["Chartreuse verte"], UnitPrice = 18.00M, Quantity = 21, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10828], Product = productsByName["Sir Rodney's Marmalade"], UnitPrice = 81.00M, Quantity = 5, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10828], Product = productsByName["Côte de Blaye"], UnitPrice = 263.50M, Quantity = 2, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines16(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10828], Product = productsByName["Côte de Blaye"], UnitPrice = 263.50M, Quantity = 2, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10829], Product = productsByName["Chang"], UnitPrice = 19.00M, Quantity = 10, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10829], Product = productsByName["Northwoods Cranberry Sauce"], UnitPrice = 40.00M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10829], Product = productsByName["Konbu"], UnitPrice = 6.00M, Quantity = 10, Discount = 0M }; session.Insert(orderLine); @@ -3008,7 +3138,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10861], Product = productsByName["Alice Mutton"], UnitPrice = 39.00M, Quantity = 42, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10861], Product = productsByName["Carnarvon Tigers"], UnitPrice = 62.50M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10861], Product = productsByName["Sir Rodney's Scones"], UnitPrice = 10.00M, Quantity = 40, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10861], Product = productsByName["Geitost"], UnitPrice = 2.50M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines17(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10861], Product = productsByName["Geitost"], UnitPrice = 2.50M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10861], Product = productsByName["Tarte au sucre"], UnitPrice = 49.30M, Quantity = 3, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10862], Product = productsByName["Queso Cabrales"], UnitPrice = 21.00M, Quantity = 25, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10862], Product = productsByName["Filo Mix"], UnitPrice = 7.00M, Quantity = 8, Discount = 0M }; session.Insert(orderLine); @@ -3109,7 +3243,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10904], Product = productsByName["Escargots de Bourgogne"], UnitPrice = 13.25M, Quantity = 15, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10904], Product = productsByName["Tarte au sucre"], UnitPrice = 49.30M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10905], Product = productsByName["Chai"], UnitPrice = 18.00M, Quantity = 20, Discount = 0.05M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10906], Product = productsByName["Sirop d'érable"], UnitPrice = 28.50M, Quantity = 15, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines18(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10906], Product = productsByName["Sirop d'érable"], UnitPrice = 28.50M, Quantity = 15, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10907], Product = productsByName["Rhönbräu Klosterbier"], UnitPrice = 7.75M, Quantity = 14, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10908], Product = productsByName["Uncle Bob's Organic Dried Pears"], UnitPrice = 30.00M, Quantity = 20, Discount = 0.05M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10908], Product = productsByName["Filo Mix"], UnitPrice = 7.00M, Quantity = 14, Discount = 0.05M }; session.Insert(orderLine); @@ -3210,7 +3348,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10946], Product = productsByName["Guaraná Fantástica"], UnitPrice = 4.50M, Quantity = 25, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10946], Product = productsByName["Original Frankfurter grüne Soße"], UnitPrice = 13.00M, Quantity = 40, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10947], Product = productsByName["Raclette Courdavault"], UnitPrice = 55.00M, Quantity = 4, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10948], Product = productsByName["Valkoinen suklaa"], UnitPrice = 16.25M, Quantity = 9, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines19(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10948], Product = productsByName["Valkoinen suklaa"], UnitPrice = 16.25M, Quantity = 9, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10948], Product = productsByName["Manjimup Dried Apples"], UnitPrice = 53.00M, Quantity = 40, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10948], Product = productsByName["Pâté chinois"], UnitPrice = 24.00M, Quantity = 4, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10949], Product = productsByName["Grandma's Boysenberry Spread"], UnitPrice = 25.00M, Quantity = 12, Discount = 0M }; session.Insert(orderLine); @@ -3311,7 +3453,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[10988], Product = productsByName["Tarte au sucre"], UnitPrice = 49.30M, Quantity = 40, Discount = 0.1M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10989], Product = productsByName["Grandma's Boysenberry Spread"], UnitPrice = 25.00M, Quantity = 40, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10989], Product = productsByName["Queso Cabrales"], UnitPrice = 21.00M, Quantity = 15, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[10989], Product = productsByName["Jack's New England Clam Chowder"], UnitPrice = 9.65M, Quantity = 4, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines20(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[10989], Product = productsByName["Jack's New England Clam Chowder"], UnitPrice = 9.65M, Quantity = 4, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10990], Product = productsByName["Sir Rodney's Scones"], UnitPrice = 10.00M, Quantity = 65, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10990], Product = productsByName["Sasquatch Ale"], UnitPrice = 14.00M, Quantity = 60, Discount = 0.15M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[10990], Product = productsByName["Pâté chinois"], UnitPrice = 24.00M, Quantity = 65, Discount = 0.15M }; session.Insert(orderLine); @@ -3412,7 +3558,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[11028], Product = productsByName["Pâté chinois"], UnitPrice = 24.00M, Quantity = 35, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11028], Product = productsByName["Raclette Courdavault"], UnitPrice = 55.00M, Quantity = 24, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11029], Product = productsByName["Gnocchi di nonna Alice"], UnitPrice = 38.00M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[11029], Product = productsByName["Vegie-spread"], UnitPrice = 43.90M, Quantity = 12, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines21(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[11029], Product = productsByName["Vegie-spread"], UnitPrice = 43.90M, Quantity = 12, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11030], Product = productsByName["Chang"], UnitPrice = 19.00M, Quantity = 100, Discount = 0.25M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11030], Product = productsByName["Chef Anton's Gumbo Mix"], UnitPrice = 21.35M, Quantity = 70, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11030], Product = productsByName["Thüringer Rostbratwurst"], UnitPrice = 123.79M, Quantity = 60, Discount = 0.25M }; session.Insert(orderLine); @@ -3513,7 +3663,11 @@ static void CreateOrderLines(IStatelessSession session, IDictionary orderLine = new OrderLine { Order = ordersById[11070], Product = productsByName["Gorgonzola Telino"], UnitPrice = 12.50M, Quantity = 20, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11071], Product = productsByName["Uncle Bob's Organic Dried Pears"], UnitPrice = 30.00M, Quantity = 15, Discount = 0.05M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11071], Product = productsByName["Konbu"], UnitPrice = 6.00M, Quantity = 10, Discount = 0.05M }; session.Insert(orderLine); - orderLine = new OrderLine { Order = ordersById[11072], Product = productsByName["Chang"], UnitPrice = 19.00M, Quantity = 8, Discount = 0M }; session.Insert(orderLine); + } + + static void CreateOrderLines22(IStatelessSession session, IDictionary ordersById, IDictionary productsByName) + { + var orderLine = new OrderLine { Order = ordersById[11072], Product = productsByName["Chang"], UnitPrice = 19.00M, Quantity = 8, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11072], Product = productsByName["Jack's New England Clam Chowder"], UnitPrice = 9.65M, Quantity = 40, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11072], Product = productsByName["Valkoinen suklaa"], UnitPrice = 16.25M, Quantity = 22, Discount = 0M }; session.Insert(orderLine); orderLine = new OrderLine { Order = ordersById[11072], Product = productsByName["Wimmers gute Semmelknödel"], UnitPrice = 33.25M, Quantity = 130, Discount = 0M }; session.Insert(orderLine); diff --git a/src/NHibernate.Test/Logging/LoggerProviderTest.cs b/src/NHibernate.Test/Logging/LoggerProviderTest.cs index ae3b852f9d4..b00bfa91fbc 100644 --- a/src/NHibernate.Test/Logging/LoggerProviderTest.cs +++ b/src/NHibernate.Test/Logging/LoggerProviderTest.cs @@ -1,4 +1,5 @@ using System; +using System.Reflection; using NUnit.Framework; namespace NHibernate.Test.Logging @@ -23,6 +24,8 @@ public void LoggerProviderCanCreateLoggers_Obsolete() [Test] public void WhenNotConfiguredAndLog4NetExistsThenUseLog4NetFactory() { + Assume.That(TestsContext.ExecutingWithVsTest, Is.False); + // NoLoggingNHibernateLogger is internal Assert.That(NHibernateLogger.For("pizza").GetType().Name, Is.Not.EqualTo("NoLoggingNHibernateLogger")); } @@ -30,6 +33,8 @@ public void WhenNotConfiguredAndLog4NetExistsThenUseLog4NetFactory() [Test, Obsolete] public void WhenNotConfiguredAndLog4NetExistsThenUseLog4NetFactory_Obsolete() { + Assume.That(TestsContext.ExecutingWithVsTest, Is.False); + Assert.That(LoggerProvider.LoggerFor("pizza"), Is.Not.InstanceOf()); // works because this is the legacy provider with a legacy logger diff --git a/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs b/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs index fbe047c53c5..98b3ac55f28 100644 --- a/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs +++ b/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs @@ -191,7 +191,7 @@ public void XmlSerialization() using (Stream stream = GetType().Assembly.GetManifestResourceStream("NHibernate.Test.MappingTest.Wicked.hbm.xml")) { HbmMapping mapping = mdp.Parse(stream); - Assert.That(mapping, Is.XmlSerializable); + NHAssert.IsXmlSerializable(mapping); } } } diff --git a/src/NHibernate.Test/NHAssert.cs b/src/NHibernate.Test/NHAssert.cs index 79667df1086..d7934f17ca2 100644 --- a/src/NHibernate.Test/NHAssert.cs +++ b/src/NHibernate.Test/NHAssert.cs @@ -1,9 +1,14 @@ using System; using System.Reflection; -using System.Text; using NUnit.Framework; using System.Collections.Generic; using System.Linq; +#if !NETFX +using System.IO; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Binary; +using System.Xml.Serialization; +#endif namespace NHibernate.Test { @@ -53,10 +58,66 @@ public static void IsSerializable(object obj) public static void IsSerializable(object obj, string message, params object[] args) { +#if NETFX Assert.That(obj, Is.BinarySerializable, message, args); +#else + if (obj == null) throw new ArgumentNullException(nameof(args)); + var serializer = new BinaryFormatter(); + var isSuccess = false; + using (var memoryStream = new MemoryStream()) + { + try + { + serializer.Serialize(memoryStream, obj); + memoryStream.Seek(0L, SeekOrigin.Begin); + var deserialized = serializer.Deserialize(memoryStream); + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + isSuccess = deserialized != null; + } + catch (SerializationException) + { + } + } + + Assert.That(isSuccess, message, args); +#endif + } + + public static void IsXmlSerializable(object obj) + { + IsXmlSerializable(obj, null, null); + } + + public static void IsXmlSerializable(object obj, string message, params object[] args) + { +#if NETFX + Assert.That(obj, Is.XmlSerializable, message, args); +#else + if (obj == null) throw new ArgumentNullException(nameof(obj)); + var isSuccess = false; + using (var memoryStream = new MemoryStream()) + { + try + { + var serializer = new XmlSerializer(obj.GetType()); + serializer.Serialize(memoryStream, obj); + memoryStream.Seek(0L, SeekOrigin.Begin); + isSuccess = serializer.Deserialize(memoryStream) != null; + } + catch (NotSupportedException) + { + } + catch (InvalidOperationException) + { + } + } + + Assert.That(isSuccess, message, args); +#endif } #endregion + private static IEnumerable ClassList(Assembly assembly, System.Type type) { IList result = new List(); @@ -72,4 +133,4 @@ public static void IsSerializable(object obj, string message, params object[] ar return result; } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs index 6d56dfefd34..61d5b603a63 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs @@ -12,10 +12,8 @@ namespace NHibernate.Test.NHSpecificTest.NH1632 [TestFixture] public class Fixture : BugTestCase { - public override string BugNumber - { - get { return "NH1632"; } - } + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver.SupportsSystemTransactions; protected override void Configure(Configuration configuration) { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs index e56ce2066c7..e1a9d4f80df 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2057/Fixture.cs @@ -1,5 +1,6 @@ using System.Threading; using System.Transactions; +using NHibernate.Engine; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH2057 @@ -7,6 +8,9 @@ namespace NHibernate.Test.NHSpecificTest.NH2057 [TestFixture] public class Fixture : BugTestCase { + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver.SupportsSystemTransactions; + [Test] public void WillCloseWhenUsingDTC() { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2176/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2176/Fixture.cs index 2f5cabedad4..6942803cf8c 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2176/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2176/Fixture.cs @@ -1,5 +1,6 @@ using System; using System.Transactions; +using NHibernate.Engine; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH2176 @@ -7,6 +8,9 @@ namespace NHibernate.Test.NHSpecificTest.NH2176 [TestFixture] public class Fixture : BugTestCase { + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver.SupportsSystemTransactions; + protected override void OnSetUp() { base.OnSetUp(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs index 0cde5572e99..1c80edf6de7 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs @@ -5,6 +5,7 @@ using System.Transactions; using NHibernate.Dialect; using NHibernate.Driver; +using NHibernate.Engine; using NUnit.Framework; using Environment = NHibernate.Cfg.Environment; @@ -14,15 +15,11 @@ namespace NHibernate.Test.NHSpecificTest.NH2420 [TestFixture] public class Fixture : BugTestCase { - public override string BugNumber - { - get { return "NH2420"; } - } + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver.SupportsSystemTransactions; - protected override bool AppliesTo(Dialect.Dialect dialect) - { - return (dialect is MsSql2005Dialect); - } + protected override bool AppliesTo(Dialect.Dialect dialect) => + dialect is MsSql2005Dialect; private string FetchConnectionStringFromConfiguration() { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2773/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2773/Fixture.cs index 7d163888e04..ab2e6dabb4f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2773/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2773/Fixture.cs @@ -38,6 +38,8 @@ protected override void OnTearDown() { [Test] public void DeserializedSession_ProxyType_ShouldBeEqualToOriginalProxyType() { + TestsContext.AssumeSystemTypeIsSerializable(); + System.Type originalProxyType = null; System.Type deserializedProxyType = null; ISession deserializedSession = null; diff --git a/src/NHibernate.Test/NHSpecificTest/NH2880/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2880/Fixture.cs index e64fe273a25..02a5dcd0df3 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2880/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2880/Fixture.cs @@ -34,6 +34,8 @@ protected override void OnSetUp() [Test] public void ProxiesFromDeserializedSessionsCanBeLoaded() { + TestsContext.AssumeSystemTypeIsSerializable(); + MemoryStream sessionMemoryStream; using (ISession s = Sfi.OpenSession()) @@ -97,4 +99,4 @@ protected override void OnTearDown() } } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/NHSpecificTest/NH2985/Model.cs b/src/NHibernate.Test/NHSpecificTest/NH2985/Model.cs index 99ba39592f2..7c322e208f7 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2985/Model.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2985/Model.cs @@ -24,7 +24,7 @@ public class WebImage public WebImage() { - OldPosition = -1; //di base un immagine � nuova. + OldPosition = -1; //di base un immagine è nuova. } /// /// @@ -36,7 +36,7 @@ public virtual Guid Id } /// - /// I dati grezzi dell'immagine, � il conenuto binario che io ottengo + /// I dati grezzi dell'immagine, è il conenuto binario che io ottengo /// scaricando l'immagine /// /// The image data. @@ -80,8 +80,8 @@ public virtual Guid Id public virtual Int32? ContextEval { get; set; } /// - /// L'immagine � trattata talvolta come una vera e propria rilevazione per cui - /// ha comunque al suo interno la possibilit� di avere uno stato associato. + /// L'immagine è trattata talvolta come una vera e propria rilevazione per cui + /// ha comunque al suo interno la possibilità di avere uno stato associato. /// public virtual Int32 Status { get; set; } @@ -96,15 +96,22 @@ public virtual Guid Id public virtual Boolean Bookmarked { get; set; } /// - /// La posizione nella ricerca precedente, -1 se � la prima apparizione. + /// La posizione nella ricerca precedente, -1 se è la prima apparizione. /// public virtual Int32 OldPosition { get; protected internal set; } /// - /// Un'immagine che non � pi� tornata + /// Un'immagine che non è più tornata /// protected internal virtual Boolean OldImage { get; set; } + /// + /// La url dell'immagine. + /// + /// The image URL. + public virtual String ImageUrl { get; set; } + +#if NETFX private Bitmap _bitmap; /// @@ -119,12 +126,6 @@ public virtual Bitmap Bitmap } } - /// - /// La url dell'immagine. - /// - /// The image URL. - public virtual String ImageUrl { get; set; } - private Bitmap CreateBitmap() { try @@ -144,6 +145,7 @@ private Bitmap CreateBitmap() } } +#endif } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs b/src/NHibernate.Test/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs index 96b83b0179d..f460546d6ad 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3023/DeadlockConnectionPoolIssueTest.cs @@ -31,11 +31,12 @@ protected override void Configure(Configuration configuration) } // Uses directly SqlConnection. - protected override bool AppliesTo(ISessionFactoryImplementor factory) - => factory.ConnectionProvider.Driver is SqlClientDriver && base.AppliesTo(factory); + protected override bool AppliesTo(ISessionFactoryImplementor factory) => + factory.ConnectionProvider.Driver is SqlClientDriver && + factory.ConnectionProvider.Driver.SupportsSystemTransactions; - protected override bool AppliesTo(Dialect.Dialect dialect) - => dialect is MsSql2000Dialect && base.AppliesTo(dialect); + protected override bool AppliesTo(Dialect.Dialect dialect) => + dialect is MsSql2000Dialect; protected override void OnSetUp() { diff --git a/src/NHibernate.Test/NHSpecificTest/NH3119/FixtureByCode.cs b/src/NHibernate.Test/NHSpecificTest/NH3119/FixtureByCode.cs index 4a145597dd9..f5538456d53 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3119/FixtureByCode.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3119/FixtureByCode.cs @@ -86,6 +86,8 @@ public void PocoComponentTuplizer_Instantiate_UsesReflectonOptimizer() [Test] public void PocoComponentTuplizerOfDeserializedConfiguration_Instantiate_UsesReflectonOptimizer() { + TestsContext.AssumeSystemTypeIsSerializable(); + MemoryStream configMemoryStream = new MemoryStream(); BinaryFormatter writer = new BinaryFormatter(); writer.Serialize(configMemoryStream, cfg); diff --git a/src/NHibernate.Test/NHSpecificTest/NH317/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH317/Fixture.cs index 74ba6a94c33..2dc9d05a8f1 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH317/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH317/Fixture.cs @@ -27,6 +27,8 @@ protected override IList Mappings [Test] public void ProxySerialization() { + TestsContext.AssumeSystemTypeIsSerializable(); + Node node = new Node(); node.Id = 1; node.Name = "Node 1"; @@ -61,4 +63,4 @@ public void ProxySerialization() s.Close(); } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/NHSpecificTest/NH3383/FixtureByCode.cs b/src/NHibernate.Test/NHSpecificTest/NH3383/FixtureByCode.cs index 8da471c71a2..ff14b7e832b 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3383/FixtureByCode.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3383/FixtureByCode.cs @@ -63,6 +63,8 @@ public void CanRoundTripSerializedMultipleCascadeStyle() [Test] public void DeserializedPropertyMapping_RefersToSameCascadeStyle() { + TestsContext.AssumeSystemTypeIsSerializable(); + var classMapping = CreateMappingClasses(); RootClass deserializedClassMapping; @@ -78,6 +80,7 @@ public void DeserializedPropertyMapping_RefersToSameCascadeStyle() AssertDeserializedMappingClasses(deserializedClassMapping); } +#if NETFX // This test uses a seperate AppDomain to simulate the loading of a Configuration that was // serialized to the disk and is later deserialized in a new process. [Test] @@ -110,6 +113,7 @@ public void DeserializedPropertyMapping_CascadeStyleNotYetInitializedOnDeseriali } } } +#endif private static RootClass CreateMappingClasses() { diff --git a/src/NHibernate.Test/NHSpecificTest/NH3487/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3487/Fixture.cs index d9ba75df001..54e6ca0dda0 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3487/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3487/Fixture.cs @@ -53,6 +53,8 @@ protected override void OnTearDown() [Test] public void CanDeserializeSessionWithEntityHashCollision() { + TestsContext.AssumeSystemTypeIsSerializable(); + IFormatter formatter = new BinaryFormatter(); byte[] serializedSessionArray; @@ -80,4 +82,4 @@ public void CanDeserializeSessionWithEntityHashCollision() } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/NHSpecificTest/NH3583/AutoFlushFixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3583/AutoFlushFixture.cs index 03dded82481..1a702a6c4ae 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3583/AutoFlushFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3583/AutoFlushFixture.cs @@ -50,9 +50,12 @@ public void ShouldAutoFlushWhenInExplicitTransaction() Assert.That(result.Count, Is.EqualTo(1)); } } + [Test] public void ShouldAutoFlushWhenInDistributedTransaction() { + Assume.That(Sfi.ConnectionProvider.Driver.SupportsSystemTransactions, Is.True); + using (new TransactionScope()) using (var session = OpenSession()) { diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj index 9d04242a1d2..02a63958926 100644 --- a/src/NHibernate.Test/NHibernate.Test.csproj +++ b/src/NHibernate.Test/NHibernate.Test.csproj @@ -2,11 +2,17 @@ The Unit Tests for NHibernate. - - net461 + net461;netcoreapp2.0 true $(NoWarn);3001;3002;3003;3005 + + NETFX;$(DefineConstants) + + + Exe + false + @@ -30,19 +36,42 @@ Always + + + + + + + + + + - + - - - - - - + + + + + + + + + + + + + + + + + + + @@ -62,12 +91,7 @@ - - - - - - + \ No newline at end of file diff --git a/src/NHibernate.Test/Program.cs b/src/NHibernate.Test/Program.cs new file mode 100644 index 00000000000..bee78f9d955 --- /dev/null +++ b/src/NHibernate.Test/Program.cs @@ -0,0 +1,12 @@ +#if NETCOREAPP2_0 +namespace NHibernate.Test +{ + public class Program + { + public static int Main(string[] args) + { + return new NUnitLite.AutoRun(typeof(Program).Assembly).Execute(args); + } + } +} +#endif \ No newline at end of file diff --git a/src/NHibernate.Test/ReadOnly/ReadOnlyCriteriaQueryTest.cs b/src/NHibernate.Test/ReadOnly/ReadOnlyCriteriaQueryTest.cs index 8db55a3bdd4..61d479794ae 100644 --- a/src/NHibernate.Test/ReadOnly/ReadOnlyCriteriaQueryTest.cs +++ b/src/NHibernate.Test/ReadOnly/ReadOnlyCriteriaQueryTest.cs @@ -1056,6 +1056,8 @@ public void Subselect() [Test] public void DetachedCriteria() { + TestsContext.AssumeSystemTypeIsSerializable(); + DetachedCriteria dc = NHibernate.Criterion.DetachedCriteria.For() .Add(Property.ForName("Name").Eq("Gavin King")) .AddOrder(Order.Asc("StudentNumber")); diff --git a/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs b/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs index 416fe5b8637..8960ce31d1b 100644 --- a/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs +++ b/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs @@ -164,11 +164,13 @@ public void ShouldNotifyAfterDistributedTransaction(bool doCommit) Assert.That(interceptor.afterTransactionCompletionCalled, Is.EqualTo(2)); } - [Description("NH2128")] [Theory] public void ShouldNotifyAfterDistributedTransactionWithOwnConnection(bool doCommit) { + if (!Sfi.ConnectionProvider.Driver.SupportsSystemTransactions) + Assert.Ignore("Driver does not support System.Transactions. Ignoring test."); + // Note: For system transaction, calling Close() on the session isn't // supported, so we don't need to test that scenario. diff --git a/src/NHibernate.Test/TestsContext.cs b/src/NHibernate.Test/TestsContext.cs new file mode 100644 index 00000000000..e82a7b640ee --- /dev/null +++ b/src/NHibernate.Test/TestsContext.cs @@ -0,0 +1,66 @@ +using NUnit.Framework; + +#if NETCOREAPP2_0 +using System.Configuration; +using System.IO; +using log4net.Repository.Hierarchy; +using NHibernate.Cfg; +using NHibernate.Cfg.ConfigurationSchema; +#endif + +namespace NHibernate.Test +{ +#if NETCOREAPP2_0 + [SetUpFixture] +#endif + public class TestsContext + { + public static bool ExecutingWithVsTest { get; } = + System.Reflection.Assembly.GetEntryAssembly()?.GetName().Name == "testhost"; + + public static void AssumeSystemTypeIsSerializable() => + Assume.That(typeof(System.Type).IsSerializable, Is.True); + +#if NETCOREAPP2_0 + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + //When .NET Core App 2.0 tests run from VS/VSTest the entry assembly is "testhost.dll" + //so we need to explicitly load the configuration + if (ExecutingWithVsTest) + { + Environment.InitializeGlobalProperties(GetTestAssemblyHibernateConfiguration()); + } + + ConfigureLog4Net(); + } + + public static IHibernateConfiguration GetTestAssemblyHibernateConfiguration() + { + var assemblyPath = + Path.Combine(TestContext.CurrentContext.TestDirectory, Path.GetFileName(typeof(TestsContext).Assembly.Location)); + var configuration = ConfigurationManager.OpenExeConfiguration(assemblyPath); + var section = configuration.GetSection(CfgXmlHelper.CfgSectionName); + return HibernateConfiguration.FromAppConfig(section.SectionInformation.GetRawXml()); + } + + private static void ConfigureLog4Net() + { + var hierarchy = (Hierarchy)log4net.LogManager.GetRepository(typeof(TestsContext).Assembly); + + var consoleAppender = new log4net.Appender.ConsoleAppender + { + Layout = new log4net.Layout.PatternLayout("%d{ABSOLUTE} %-5p %c{1}:%L - %m%n"), + }; + + ((Logger)hierarchy.GetLogger("NHibernate.Hql.Ast.ANTLR")).Level = log4net.Core.Level.Off; + ((Logger)hierarchy.GetLogger("NHibernate.SQL")).Level = log4net.Core.Level.Off; + ((Logger)hierarchy.GetLogger("NHibernate.AdoNet.AbstractBatcher")).Level = log4net.Core.Level.Off; + ((Logger)hierarchy.GetLogger("NHibernate.Tool.hbm2ddl.SchemaExport")).Level = log4net.Core.Level.Error; + hierarchy.Root.Level = log4net.Core.Level.Warn; + hierarchy.Root.AddAppender(consoleAppender); + hierarchy.Configured = true; + } +#endif + } +} diff --git a/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs b/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs index 3d0ae2e6d9f..62141b92a21 100644 --- a/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs +++ b/src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs @@ -259,7 +259,6 @@ public void WhenConfiguredOnlyExplicitAutoQuote() // Test uses the default dialect driver, which will not accept Odbc or OleDb connection strings. if (typeof(OdbcDriver).IsAssignableFrom(driverClass) || typeof(OleDbDriver).IsAssignableFrom(driverClass)) Assert.Ignore("Test is not compatible with OleDb or ODBC driver connection strings"); - var configuredDialect = Dialect.Dialect.GetDialect(); if(!configuredDialect.DefaultProperties.ContainsKey(Environment.ConnectionDriver)) { diff --git a/src/NHibernate.Test/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs b/src/NHibernate.Test/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs index 72d244ca927..57e056f0dab 100644 --- a/src/NHibernate.Test/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs +++ b/src/NHibernate.Test/Tools/hbm2ddl/SchemaValidator/SchemaValidateFixture.cs @@ -41,6 +41,7 @@ public void ShouldVerifySameTable() validator.Validate(); } +#if NETFX [Test, SetCulture("tr-TR"), SetUICulture("tr-TR")] public void ShouldVerifySameTableTurkish() { @@ -69,6 +70,7 @@ public void ShouldVerifySameTableTurkish() export.Drop(true, true); } } +#endif [Test] public void ShouldNotVerifyModifiedTable() diff --git a/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs b/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs index c53a2818d13..4a5be9d12d2 100644 --- a/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs +++ b/src/NHibernate.Test/TransformTests/AliasToBeanResultTransformerFixture.cs @@ -245,6 +245,8 @@ public void ToPropertiesInsensitivelyDuplicated_WithoutAnyProjections() [Test] public void Serialization() { + TestsContext.AssumeSystemTypeIsSerializable(); + AssertSerialization(); AssertSerialization(); AssertSerialization(); @@ -293,4 +295,4 @@ private void AssertSerialization() AssertCardinalityNameAndId(transformer: transformer); } } -} \ No newline at end of file +} diff --git a/src/NHibernate.Test/TypesTest/SerializableTypesFixture.cs b/src/NHibernate.Test/TypesTest/SerializableTypesFixture.cs index 61b4b29e827..6c6e6d72cf0 100644 --- a/src/NHibernate.Test/TypesTest/SerializableTypesFixture.cs +++ b/src/NHibernate.Test/TypesTest/SerializableTypesFixture.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Reflection; using NHibernate.Type; using NUnit.Framework; @@ -17,12 +19,28 @@ public void AllEmbeddedTypesAreMarkedSerializable() [Test] public void EachEmbeddedBasicTypeIsSerializable() { - FieldInfo[] builtInCustomTypes = typeof(NHibernateUtil).GetFields(BindingFlags.Public | BindingFlags.Static); - foreach (FieldInfo fieldInfo in builtInCustomTypes) + var testExplicit = new HashSet { - IType ntp = (IType) fieldInfo.GetValue(null); + "Serializable", + "Object" + }; + + var builtInCustomTypes = + typeof(NHibernateUtil) + .GetFields(BindingFlags.Public | BindingFlags.Static) + .Where(f => !testExplicit.Contains(f.Name)); + + foreach (var fieldInfo in builtInCustomTypes) + { + var ntp = (IType) fieldInfo.GetValue(null); NHAssert.IsSerializable(ntp, fieldInfo.Name + " is not serializable"); } + + if (typeof(System.Type).IsSerializable) + { + NHAssert.IsSerializable(NHibernateUtil.Serializable); + NHAssert.IsSerializable(NHibernateUtil.Object); + } } } } \ No newline at end of file diff --git a/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs b/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs index a3cc098edcc..86aec92ae2e 100644 --- a/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs +++ b/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs @@ -82,6 +82,7 @@ public void NoTypeFoundReturnsNull() Assert.IsNull(noType); } +#if NETFX [Test] public void TypeFoundInNotLoadedAssembly() { @@ -91,6 +92,7 @@ public void TypeFoundInNotLoadedAssembly() System.Type sameType = ReflectHelper.TypeFromAssembly("System.Web.HttpRequest", "System.Web", false); Assert.AreEqual(httpRequest, sameType, "should be the exact same Type"); } +#endif [Test] public void SystemTypes() @@ -185,4 +187,4 @@ public class MyImplementation: IMyInterface public string Name { get; set; } public string Description { get; set; } } -} \ No newline at end of file +} diff --git a/src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj b/src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj index eea8bca710c..c055b074610 100644 --- a/src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj +++ b/src/NHibernate.TestDatabaseSetup/NHibernate.TestDatabaseSetup.csproj @@ -3,13 +3,23 @@ NHibernate.TestDatabaseSetup Test Database Setup for NHibernate. - net461 + net461;netcoreapp2.0 true $(NoWarn);3001;3002;3003;3005 + + NETFX;$(DefineConstants) + + + Exe + false + + + + diff --git a/src/NHibernate.TestDatabaseSetup/Program.cs b/src/NHibernate.TestDatabaseSetup/Program.cs new file mode 100644 index 00000000000..c85444f1fe4 --- /dev/null +++ b/src/NHibernate.TestDatabaseSetup/Program.cs @@ -0,0 +1,12 @@ +#if NETCOREAPP2_0 +namespace NHibernate.TestDatabaseSetup +{ + public class Program + { + public static int Main(string[] args) + { + return new NUnitLite.AutoRun(typeof(Program).Assembly).Execute(args); + } + } +} +#endif \ No newline at end of file diff --git a/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs b/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs index 35d5a35e0d0..46944c3abf3 100644 --- a/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs +++ b/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs @@ -2,8 +2,10 @@ using System.Collections.Generic; using System.Data.Odbc; using System.Data.SqlClient; +#if NETFX using System.Data.SqlServerCe; using System.Data.SQLite; +#endif using System.IO; using FirebirdSql.Data.FirebirdClient; using NHibernate.Test; @@ -19,15 +21,17 @@ public class DatabaseSetup { {"NHibernate.Driver.SqlClientDriver", SetupSqlServer}, {"NHibernate.Driver.Sql2008ClientDriver", SetupSqlServer}, - {"NHibernate.Driver.OdbcDriver", SetupSqlServerOdbc}, {"NHibernate.Driver.FirebirdClientDriver", SetupFirebird}, - {"NHibernate.Driver.SQLite20Driver", SetupSQLite}, {"NHibernate.Driver.NpgsqlDriver", SetupNpgsql}, {"NHibernate.Driver.OracleDataClientDriver", SetupOracle}, {"NHibernate.Driver.MySqlDataDriver", SetupMySql}, {"NHibernate.Driver.OracleClientDriver", SetupOracle}, {"NHibernate.Driver.OracleManagedDataClientDriver", SetupOracle}, + {"NHibernate.Driver.OdbcDriver", SetupSqlServerOdbc}, +#if NETFX + {"NHibernate.Driver.SQLite20Driver", SetupSQLite}, {"NHibernate.Driver.SqlServerCeDriver", SetupSqlServerCe} +#endif }; private static void SetupMySql(Cfg.Configuration obj) @@ -118,6 +122,7 @@ private static void SetupFirebird(Cfg.Configuration cfg) FbConnection.CreateDatabase(connStr, pageSize:16384, forcedWrites:false); } +#if NETFX private static void SetupSqlServerCe(Cfg.Configuration cfg) { var connStr = cfg.Properties[Cfg.Environment.ConnectionString]; @@ -139,6 +144,7 @@ private static void SetupSqlServerCe(Cfg.Configuration cfg) en.CreateDatabase(); } } +#endif private static void SetupNpgsql(Cfg.Configuration cfg) { @@ -184,6 +190,7 @@ RETURNS uuid } } +#if NETFX private static void SetupSQLite(Cfg.Configuration cfg) { var connStr = cfg.Properties[Cfg.Environment.ConnectionString]; @@ -200,6 +207,7 @@ private static void SetupSQLite(Cfg.Configuration cfg) Console.WriteLine(e); } } +#endif private static void SetupOracle(Cfg.Configuration cfg) { diff --git a/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs b/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs index 716bf24fc85..dfda861faab 100644 --- a/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs +++ b/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs @@ -1,3 +1,4 @@ +#if NETFX using System; using System.Data.Common; using System.Text; @@ -163,3 +164,4 @@ protected override void Dispose(bool isDisposing) } } } +#endif diff --git a/src/NHibernate/AdoNet/SqlClientBatchingBatcherFactory.cs b/src/NHibernate/AdoNet/SqlClientBatchingBatcherFactory.cs index 61304f1241e..f14191da55d 100644 --- a/src/NHibernate/AdoNet/SqlClientBatchingBatcherFactory.cs +++ b/src/NHibernate/AdoNet/SqlClientBatchingBatcherFactory.cs @@ -1,3 +1,4 @@ +#if NETFX using NHibernate.Engine; namespace NHibernate.AdoNet @@ -9,4 +10,5 @@ public virtual IBatcher CreateBatcher(ConnectionManager connectionManager, IInte return new SqlClientBatchingBatcher(connectionManager, interceptor); } } -} \ No newline at end of file +} +#endif diff --git a/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs b/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs index 9a36255c77c..57e681e16e3 100644 --- a/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs +++ b/src/NHibernate/AdoNet/SqlClientSqlCommandSet.cs @@ -1,3 +1,4 @@ +#if NETFX using System; using System.Data.SqlClient; using System.Diagnostics; @@ -135,3 +136,4 @@ public void Dispose() } } } +#endif diff --git a/src/NHibernate/Async/AdoNet/SqlClientBatchingBatcher.cs b/src/NHibernate/Async/AdoNet/SqlClientBatchingBatcher.cs index 6c84e3f517f..40218f08b0f 100644 --- a/src/NHibernate/Async/AdoNet/SqlClientBatchingBatcher.cs +++ b/src/NHibernate/Async/AdoNet/SqlClientBatchingBatcher.cs @@ -8,6 +8,7 @@ //------------------------------------------------------------------------------ +#if NETFX using System; using System.Data.Common; using System.Text; @@ -94,3 +95,4 @@ protected override async Task DoExecuteBatchAsync(DbCommand ps, CancellationToke } } } +#endif diff --git a/src/NHibernate/Bytecode/Lightweight/ReflectionOptimizer.cs b/src/NHibernate/Bytecode/Lightweight/ReflectionOptimizer.cs index 7bdff38d8da..06927647da6 100644 --- a/src/NHibernate/Bytecode/Lightweight/ReflectionOptimizer.cs +++ b/src/NHibernate/Bytecode/Lightweight/ReflectionOptimizer.cs @@ -1,3 +1,4 @@ +using System; using System.Reflection; using System.Reflection.Emit; using System.Security; @@ -101,9 +102,9 @@ protected virtual void ThrowExceptionForNoDefaultCtor(System.Type type) protected DynamicMethod CreateDynamicMethod(System.Type returnType, System.Type[] argumentTypes) { System.Type owner = mappedType.IsInterface ? typeof (object) : mappedType; -#pragma warning disable 618 +#pragma warning disable 612,618 bool canSkipChecks = SecurityManager.IsGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess)); -#pragma warning restore 618 +#pragma warning restore 612,618 return new DynamicMethod(string.Empty, returnType, argumentTypes, owner, canSkipChecks); } diff --git a/src/NHibernate/Cfg/Configuration.cs b/src/NHibernate/Cfg/Configuration.cs index 01cf85eebc0..f09ce738cd7 100644 --- a/src/NHibernate/Cfg/Configuration.cs +++ b/src/NHibernate/Cfg/Configuration.cs @@ -1429,10 +1429,10 @@ private void AddProperties(ISessionFactoryConfiguration factoryConfiguration) /// public Configuration Configure() { - var hc = ConfigurationManager.GetSection(CfgXmlHelper.CfgSectionName) as IHibernateConfiguration; - if (hc != null && hc.SessionFactory != null) + var sessionFactoryConfiguration = Environment.HibernateConfiguration?.SessionFactory; + if (sessionFactoryConfiguration != null) { - return DoConfigure(hc.SessionFactory); + return DoConfigure(sessionFactoryConfiguration); } else { @@ -1450,30 +1450,10 @@ public Configuration Configure() /// public Configuration Configure(string fileName) { - return Configure(fileName, false); - } - - private Configuration Configure(string fileName, bool ignoreSessionFactoryConfig) - { - if (ignoreSessionFactoryConfig) - { - Environment.ResetSessionFactoryProperties(); - properties = Environment.Properties; - } - - XmlTextReader reader = null; - try + using (var reader = new XmlTextReader(fileName)) { - reader = new XmlTextReader(fileName); return Configure(reader); } - finally - { - if (reader != null) - { - reader.Close(); - } - } } /// @@ -1488,33 +1468,23 @@ private Configuration Configure(string fileName, bool ignoreSessionFactoryConfig public Configuration Configure(Assembly assembly, string resourceName) { if (assembly == null) - { - throw new HibernateException("Could not configure NHibernate.", new ArgumentNullException("assembly")); - } + throw new HibernateException("Could not configure NHibernate.", new ArgumentNullException(nameof(assembly))); if (resourceName == null) - { - throw new HibernateException("Could not configure NHibernate.", new ArgumentNullException("resourceName")); - } + throw new HibernateException("Could not configure NHibernate.", new ArgumentNullException(nameof(resourceName))); - Stream stream = null; - try + using (var stream = assembly.GetManifestResourceStream(resourceName)) { - stream = assembly.GetManifestResourceStream(resourceName); if (stream == null) { // resource does not exist - throw appropriate exception - throw new HibernateException("A ManifestResourceStream could not be created for the resource " + resourceName - + " in Assembly " + assembly.FullName); + throw new HibernateException( + "A ManifestResourceStream could not be created for the resource " + resourceName + " in Assembly " + assembly.FullName); } - return Configure(new XmlTextReader(stream)); - } - finally - { - if (stream != null) + using (var reader = new XmlTextReader(stream)) { - stream.Close(); + return Configure(reader); } } } diff --git a/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs b/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs index 83c34a89ea1..b4a24ad59c1 100644 --- a/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs +++ b/src/NHibernate/Cfg/ConfigurationSchema/HibernateConfiguration.cs @@ -55,10 +55,17 @@ private HibernateConfiguration(XmlReader hbConfigurationReader, bool fromAppSett Parse(nav, fromAppSetting); } - internal static HibernateConfiguration FromAppConfig(XmlNode node) + public static HibernateConfiguration FromAppConfig(XmlNode node) { - XmlTextReader reader = new XmlTextReader(node.OuterXml, XmlNodeType.Document, null); - return new HibernateConfiguration(reader, true); + return FromAppConfig(node.OuterXml); + } + + public static HibernateConfiguration FromAppConfig(string xml) + { + using (var reader = new XmlTextReader(xml, XmlNodeType.Document, null)) + { + return new HibernateConfiguration(reader, true); + } } private XmlReaderSettings GetSettings() diff --git a/src/NHibernate/Cfg/Environment.cs b/src/NHibernate/Cfg/Environment.cs index 97fd19b075b..d1814ba9f29 100644 --- a/src/NHibernate/Cfg/Environment.cs +++ b/src/NHibernate/Cfg/Environment.cs @@ -273,7 +273,7 @@ public static string Version /// public const string TrackSessionId = "track_session_id"; - private static readonly Dictionary GlobalProperties; + private static readonly Dictionary GlobalProperties = new Dictionary(); private static IBytecodeProvider BytecodeProviderInstance; private static bool EnableReflectionOptimizer; @@ -295,9 +295,30 @@ static Environment() log.Info("NHibernate {0}", Version); } - GlobalProperties = new Dictionary(); - GlobalProperties[PropertyUseReflectionOptimizer] = bool.TrueString; - LoadGlobalPropertiesFromAppConfig(); + InitializeGlobalProperties(GetHibernateConfiguration()); + } + + public static void InitializeGlobalProperties(IHibernateConfiguration config) + { + GlobalProperties.Clear(); + if (config != null) + { + HibernateConfiguration = config; + GlobalProperties[PropertyBytecodeProvider] = config.ByteCodeProviderType; + GlobalProperties[PropertyUseReflectionOptimizer] = config.UseReflectionOptimizer.ToString(); + if (config.SessionFactory != null) + { + foreach (var kvp in config.SessionFactory.Properties) + { + GlobalProperties[kvp.Key] = kvp.Value; + } + } + } + else + { + GlobalProperties[PropertyUseReflectionOptimizer] = bool.TrueString; + } + VerifyProperties(GlobalProperties); BytecodeProviderInstance = BuildBytecodeProvider(GlobalProperties); @@ -309,57 +330,26 @@ static Environment() } } - private static void LoadGlobalPropertiesFromAppConfig() + internal static IHibernateConfiguration HibernateConfiguration { get; private set; } + + private static IHibernateConfiguration GetHibernateConfiguration() { object config = ConfigurationManager.GetSection(CfgXmlHelper.CfgSectionName); - if (config == null) { log.Info("{0} section not found in application configuration file", CfgXmlHelper.CfgSectionName); - return; + return null; } var nhConfig = config as IHibernateConfiguration; if (nhConfig == null) { log.Info( - "{0} section handler, in application configuration file, is not IHibernateConfiguration, section ignored", - CfgXmlHelper.CfgSectionName); - return; + "{0} section handler, in application configuration file, is not IHibernateConfiguration, section ignored", + CfgXmlHelper.CfgSectionName); } - GlobalProperties[PropertyBytecodeProvider] = nhConfig.ByteCodeProviderType; - GlobalProperties[PropertyUseReflectionOptimizer] = nhConfig.UseReflectionOptimizer.ToString(); - if (nhConfig.SessionFactory != null) - { - foreach (var kvp in nhConfig.SessionFactory.Properties) - { - GlobalProperties[kvp.Key] = kvp.Value; - } - } - } - - internal static void ResetSessionFactoryProperties() - { - string savedBytecodeProvider; - GlobalProperties.TryGetValue(PropertyBytecodeProvider, out savedBytecodeProvider); - // Save values loaded and used in static constructor - - string savedUseReflectionOptimizer; - GlobalProperties.TryGetValue(PropertyUseReflectionOptimizer, out savedUseReflectionOptimizer); - // Clean all property loaded from app.config - GlobalProperties.Clear(); - - // Restore values loaded and used in static constructor - if (savedBytecodeProvider != null) - { - GlobalProperties[PropertyBytecodeProvider] = savedBytecodeProvider; - } - - if (savedUseReflectionOptimizer != null) - { - GlobalProperties[PropertyUseReflectionOptimizer] = savedUseReflectionOptimizer; - } + return nhConfig; } /// diff --git a/src/NHibernate/Context/CallSessionContext.cs b/src/NHibernate/Context/CallSessionContext.cs index 9b6d2b3ce83..559619a5464 100644 --- a/src/NHibernate/Context/CallSessionContext.cs +++ b/src/NHibernate/Context/CallSessionContext.cs @@ -1,20 +1,31 @@ using System; using System.Collections; -using System.Runtime.Remoting.Messaging; - +using System.Threading; using NHibernate.Engine; +#if NETFX +using System.Runtime.Remoting.Messaging; +#endif namespace NHibernate.Context { +#pragma warning disable CS1574 /// /// Provides a current session /// for each . - /// Not recommended for .NET 2.0 web applications. + /// Uses instead if run under .NET Core/.NET Standard. + /// + /// Not recommended for .NET 2.0 web applications. + /// /// +#pragma warning restore CS1574 [Serializable] public class CallSessionContext : MapBasedSessionContext { + #if NETFX private const string SessionFactoryMapKey = "NHibernate.Context.CallSessionContext.SessionFactoryMapKey"; + #else + private static readonly AsyncLocal SessionFactoryMap = new AsyncLocal(); + #endif public CallSessionContext(ISessionFactoryImplementor factory) : base(factory) { @@ -25,7 +36,11 @@ public CallSessionContext(ISessionFactoryImplementor factory) : base(factory) /// protected override void SetMap(IDictionary value) { +#if NETFX CallContext.SetData(SessionFactoryMapKey, value); +#else + SessionFactoryMap.Value = value; +#endif } /// @@ -33,7 +48,11 @@ protected override void SetMap(IDictionary value) /// protected override IDictionary GetMap() { +#if NETFX return CallContext.GetData(SessionFactoryMapKey) as IDictionary; +#else + return SessionFactoryMap.Value; +#endif } } -} \ No newline at end of file +} diff --git a/src/NHibernate/Driver/DriverBase.cs b/src/NHibernate/Driver/DriverBase.cs index 45228121e11..c647ec0ff82 100644 --- a/src/NHibernate/Driver/DriverBase.cs +++ b/src/NHibernate/Driver/DriverBase.cs @@ -313,9 +313,15 @@ public DbParameter GenerateOutputParameter(DbCommand command) public virtual bool RequiresTimeSpanForTime => false; +#if NETCOREAPP2_0 + public virtual bool SupportsSystemTransactions => false; + + public virtual bool SupportsNullEnlistment => false; +#else public virtual bool SupportsSystemTransactions => true; public virtual bool SupportsNullEnlistment => true; +#endif /// public virtual bool SupportsEnlistmentWhenAutoEnlistmentIsDisabled => true; diff --git a/src/NHibernate/Driver/OdbcDriver.cs b/src/NHibernate/Driver/OdbcDriver.cs index 73ec475166d..9bbb43e1989 100644 --- a/src/NHibernate/Driver/OdbcDriver.cs +++ b/src/NHibernate/Driver/OdbcDriver.cs @@ -15,7 +15,12 @@ namespace NHibernate.Driver /// /// Always look for a native .NET DataProvider before using the Odbc DataProvider. /// - public class OdbcDriver : DriverBase + public class OdbcDriver +#if NETFX + : DriverBase +#else + : ReflectionBasedDriver +#endif { private static readonly INHibernateLogger Log = NHibernateLogger.For(typeof(OdbcDriver)); @@ -34,6 +39,12 @@ public override void Configure(IDictionary settings) } } +#if !NETFX + public OdbcDriver() + : base("System.Data.Odbc", "System.Data.Odbc.OdbcConnection", "System.Data.Odbc.OdbcCommand") + { + } +#else public override DbConnection CreateConnection() { return new OdbcConnection(); @@ -43,6 +54,7 @@ public override DbCommand CreateCommand() { return new OdbcCommand(); } +#endif public override bool UseNamedPrefixInSql { diff --git a/src/NHibernate/Driver/OleDbDriver.cs b/src/NHibernate/Driver/OleDbDriver.cs index cb0d00c63c8..64012793758 100644 --- a/src/NHibernate/Driver/OleDbDriver.cs +++ b/src/NHibernate/Driver/OleDbDriver.cs @@ -10,12 +10,20 @@ namespace NHibernate.Driver /// /// Always look for a native .NET DataProvider before using the OleDb DataProvider. /// - public class OleDbDriver : DriverBase + public class OleDbDriver +#if NETFX + : DriverBase +#else + : ReflectionBasedDriver +#endif { + +#if !NETFX public OleDbDriver() + : base ("System.Data.OleDb", "System.Data.OleDb.OleDbConnection", "System.Data.OleDb.OleDbCommand") { } - +#else public override DbConnection CreateConnection() { return new OleDbConnection(); @@ -25,6 +33,7 @@ public override DbCommand CreateCommand() { return new OleDbCommand(); } +#endif public override bool UseNamedPrefixInSql { @@ -49,4 +58,4 @@ public override bool SupportsMultipleOpenReaders get { return false; } } } -} \ No newline at end of file +} diff --git a/src/NHibernate/Driver/OracleClientDriver.cs b/src/NHibernate/Driver/OracleClientDriver.cs index df302b3c1d8..334a1f09f67 100644 --- a/src/NHibernate/Driver/OracleClientDriver.cs +++ b/src/NHibernate/Driver/OracleClientDriver.cs @@ -14,8 +14,12 @@ public class OracleClientDriver : ReflectionBasedDriver public OracleClientDriver() : base( + "System.Data.OracleClient", +#if NETFX + "System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", +#else "System.Data.OracleClient", - "System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", +#endif "System.Data.OracleClient.OracleConnection", "System.Data.OracleClient.OracleCommand") { } @@ -60,4 +64,4 @@ protected override void OnBeforePrepare(DbCommand command) " Consider using OracleDataClientDriver instead."); } } -} \ No newline at end of file +} diff --git a/src/NHibernate/Driver/ReflectionBasedDriver.cs b/src/NHibernate/Driver/ReflectionBasedDriver.cs index e606ee551e0..0d19b5a9776 100644 --- a/src/NHibernate/Driver/ReflectionBasedDriver.cs +++ b/src/NHibernate/Driver/ReflectionBasedDriver.cs @@ -38,7 +38,6 @@ protected ReflectionBasedDriver(string driverAssemblyName, string connectionType /// Assembly to load the types from. /// Connection type name. /// Command type name. - /// protected ReflectionBasedDriver(string providerInvariantName, string driverAssemblyName, string connectionTypeName, string commandTypeName) { // Try to get the types from an already loaded assembly @@ -47,12 +46,16 @@ protected ReflectionBasedDriver(string providerInvariantName, string driverAssem if (connectionType == null || commandType == null) { +#if NETFX if (string.IsNullOrEmpty(providerInvariantName)) { +#endif throw new HibernateException(string.Format(ReflectionTypedProviderExceptionMessageTemplate, driverAssemblyName)); +#if NETFX } var factory = DbProviderFactories.GetFactory(providerInvariantName); connectionCommandProvider = new DbProviderFactoryDriveConnectionCommandProvider(factory); +#endif } else { @@ -71,4 +74,4 @@ public override DbCommand CreateCommand() return connectionCommandProvider.CreateCommand(); } } -} \ No newline at end of file +} diff --git a/src/NHibernate/Driver/Sql2008ClientDriver.cs b/src/NHibernate/Driver/Sql2008ClientDriver.cs index d6ba53d8627..0068832139f 100644 --- a/src/NHibernate/Driver/Sql2008ClientDriver.cs +++ b/src/NHibernate/Driver/Sql2008ClientDriver.cs @@ -1,7 +1,7 @@ using System; using System.Data; using System.Data.Common; -using System.Data.SqlClient; +using NHibernate.Util; namespace NHibernate.Driver { @@ -9,17 +9,23 @@ public class Sql2008ClientDriver : SqlClientDriver { const byte MaxTime = 5; + #if NETFX + private static readonly Action SetSqlDbType = (p, t) => ((System.Data.SqlClient.SqlParameter) p).SqlDbType = t; + #else + private static readonly Action SetSqlDbType = DelegateHelper.BuildPropertySetter(System.Type.GetType("System.Data.SqlClient.SqlParameter, System.Data.SqlClient", true), "SqlDbType"); + #endif + protected override void InitializeParameter(DbParameter dbParam, string name, SqlTypes.SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); switch (sqlType.DbType) { case DbType.Time: - ((SqlParameter) dbParam).SqlDbType = SqlDbType.Time; + SetSqlDbType(dbParam, SqlDbType.Time); dbParam.Size = MaxTime; break; case DbType.Date: - ((SqlParameter) dbParam).SqlDbType = SqlDbType.Date; + SetSqlDbType(dbParam, SqlDbType.Date); break; } } diff --git a/src/NHibernate/Driver/SqlClientDriver.cs b/src/NHibernate/Driver/SqlClientDriver.cs index a4101d6ba9d..b9849ae7b59 100644 --- a/src/NHibernate/Driver/SqlClientDriver.cs +++ b/src/NHibernate/Driver/SqlClientDriver.cs @@ -12,7 +12,12 @@ namespace NHibernate.Driver /// /// A NHibernate Driver for using the SqlClient DataProvider /// - public class SqlClientDriver : DriverBase, IEmbeddedBatcherFactoryProvider + public class SqlClientDriver +#if NETFX + : DriverBase, IEmbeddedBatcherFactoryProvider +#else + : ReflectionBasedDriver +#endif { public const int MaxSizeForAnsiClob = 2147483647; // int.MaxValue public const int MaxSizeForClob = 1073741823; // int.MaxValue / 2 @@ -40,6 +45,12 @@ public override void Configure(IDictionary settings) _dialect = Dialect.Dialect.GetDialect(settings); } +#if !NETFX + public SqlClientDriver() + : base("System.Data.SqlClient", "System.Data.SqlClient.SqlConnection", "System.Data.SqlClient.SqlCommand") + { + } +#else /// /// Creates an uninitialized object for /// the SqlClientDriver. @@ -60,6 +71,13 @@ public override DbCommand CreateCommand() return new System.Data.SqlClient.SqlCommand(); } + System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass + { + get { return typeof(SqlClientBatchingBatcherFactory); } + } +#endif + + /// /// MsSql requires the use of a Named Prefix in the SQL statement. /// @@ -111,7 +129,7 @@ public override bool SupportsMultipleOpenReaders protected override void InitializeParameter(DbParameter dbParam, string name, SqlType sqlType) { base.InitializeParameter(dbParam, name, sqlType); - + // Defaults size/precision/scale switch (dbParam.DbType) { @@ -239,14 +257,6 @@ protected static bool IsBlob(DbParameter dbParam, SqlType sqlType) return (sqlType is BinaryBlobSqlType) || ((DbType.Binary == dbParam.DbType) && sqlType.LengthDefined && (sqlType.Length > MaxSizeForLengthLimitedBinary)); } - #region IEmbeddedBatcherFactoryProvider Members - - System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass - { - get { return typeof(SqlClientBatchingBatcherFactory); } - } - - #endregion public override IResultSetsCommand GetResultSetsCommand(ISessionImplementor session) { diff --git a/src/NHibernate/Linq/Functions/StringGenerator.cs b/src/NHibernate/Linq/Functions/StringGenerator.cs index 960280e746a..7fa41faac01 100644 --- a/src/NHibernate/Linq/Functions/StringGenerator.cs +++ b/src/NHibernate/Linq/Functions/StringGenerator.cs @@ -241,13 +241,18 @@ public class TrimGenerator : BaseHqlGeneratorForMethod { public TrimGenerator() { - SupportedMethods = new[] - { - ReflectHelper.GetMethodDefinition(s => s.Trim()), - ReflectHelper.GetMethodDefinition(s => s.Trim('a')), - ReflectHelper.GetMethodDefinition(s => s.TrimStart('a')), - ReflectHelper.GetMethodDefinition(s => s.TrimEnd('a')) - }; + SupportedMethods = new HashSet + { + ReflectHelper.GetMethodDefinition(s => s.Trim()), + ReflectHelper.GetMethodDefinition(s => s.Trim('a')), + ReflectHelper.GetMethodDefinition(s => s.Trim('a', 'a')), + ReflectHelper.GetMethodDefinition(s => s.TrimStart()), + ReflectHelper.GetMethodDefinition(s => s.TrimStart('a')), + ReflectHelper.GetMethodDefinition(s => s.TrimStart('a', 'a')), + ReflectHelper.GetMethodDefinition(s => s.TrimEnd()), + ReflectHelper.GetMethodDefinition(s => s.TrimEnd('a')), + ReflectHelper.GetMethodDefinition(s => s.TrimEnd('a', 'a')) + }; } public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor) @@ -260,13 +265,9 @@ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, else trimWhere = "both"; - string trimChars = ""; - if (method.GetParameters().Length > 0) - foreach (char c in (char[])((ConstantExpression)arguments[0]).Value) - trimChars += c; - + var trimChars = ExtractTrimChars(arguments); - if (trimChars == "") + if (string.IsNullOrEmpty(trimChars)) { return treeBuilder.MethodCall("trim", treeBuilder.Ident(trimWhere), treeBuilder.Ident("from"), visitor.Visit(targetObject).AsExpression()); } @@ -275,6 +276,20 @@ public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, return treeBuilder.MethodCall("trim", treeBuilder.Ident(trimWhere), treeBuilder.Constant(trimChars), treeBuilder.Ident("from"), visitor.Visit(targetObject).AsExpression()); } } + + private static string ExtractTrimChars(IReadOnlyList arguments) + { + if (arguments.Count > 0) + { + var constantExpression = (ConstantExpression) arguments[0]; + if (constantExpression.Value is char c) + return c.ToString(); + if (constantExpression.Value is char[] chars) + return new string(chars); + } + + return string.Empty; + } } public class ToStringRuntimeMethodHqlGenerator : IRuntimeMethodHqlGenerator diff --git a/src/NHibernate/NHibernate.csproj b/src/NHibernate/NHibernate.csproj index 73ac2c9775e..294821d6a1e 100644 --- a/src/NHibernate/NHibernate.csproj +++ b/src/NHibernate/NHibernate.csproj @@ -3,8 +3,8 @@ An object persistence library for relational databases. - net461 - $(NoWarn);3001;3002;3003;3005;1591 + netstandard2.0;net461;netcoreapp2.0 + $(NoWarn);3001;3002;3003;3005;1591;419 True true ..\NHibernate.snk @@ -13,6 +13,10 @@ NHibernate is a mature, open source object-relational mapper for the .NET framework. It is actively developed, fully featured and used in thousands of successful projects. ORM; O/RM; DataBase; DAL; ObjectRelationalMapping; NHibernate; ADO.Net; Core + + + NETFX;$(DefineConstants) + @@ -41,12 +45,26 @@ - + + + + + + + + + + + + + + + ./ diff --git a/src/NHibernate/Proxy/DynamicProxy/DefaultProxyAssemblyBuilder.cs b/src/NHibernate/Proxy/DynamicProxy/DefaultProxyAssemblyBuilder.cs index a88f78034e8..541e06a61ea 100644 --- a/src/NHibernate/Proxy/DynamicProxy/DefaultProxyAssemblyBuilder.cs +++ b/src/NHibernate/Proxy/DynamicProxy/DefaultProxyAssemblyBuilder.cs @@ -8,17 +8,17 @@ public class DefaultProxyAssemblyBuilder : IProxyAssemblyBuilder { public AssemblyBuilder DefineDynamicAssembly(AppDomain appDomain, AssemblyName name) { -#if DEBUG +#if DEBUG && NETFX AssemblyBuilderAccess access = AssemblyBuilderAccess.RunAndSave; #else AssemblyBuilderAccess access = AssemblyBuilderAccess.Run; #endif - return appDomain.DefineDynamicAssembly(name, access); + return AssemblyBuilder.DefineDynamicAssembly(name, access); } public ModuleBuilder DefineDynamicModule(AssemblyBuilder assemblyBuilder, string moduleName) { -#if DEBUG +#if DEBUG && NETFX ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(moduleName, string.Format("{0}.mod", moduleName), true); #else diff --git a/teamcity.build b/teamcity.build index 453780e8de2..790ab2988ac 100644 --- a/teamcity.build +++ b/teamcity.build @@ -3,6 +3,7 @@ + @@ -15,9 +16,9 @@ - + - + @@ -130,7 +131,7 @@ - + @@ -149,7 +150,7 @@ - +