1
+ properties {
2
+ $Database = " SqlServer2012" ;
3
+ $ConnectionString = $null ;
4
+ }
5
+
6
+ Task Default - depends Build, Test
7
+
8
+ Task Set-Configuration {
9
+ $configDir = (Join-Path ' .' ' current-test-configuration' )
10
+ # Configuration matrix
11
+ $allSettings = @ {
12
+ ' Firebird' = @ {
13
+ ' connection.connection_string' = ' DataSource=localhost;Database=nhibernate;User ID=SYSDBA;Password=masterkey;MaxPoolSize=200;' ;
14
+ ' connection.driver_class' = ' NHibernate.Driver.FirebirdClientDriver' ;
15
+ ' dialect' = ' NHibernate.Dialect.FirebirdDialect'
16
+ };
17
+ ' MySQL' = @ {
18
+ ' connection.connection_string' = ' Server=127.0.0.1;Uid=root;Pwd=Password12!;Database=nhibernate;Old Guids=True;' ;
19
+ ' connection.driver_class' = ' NHibernate.Driver.MySqlDataDriver' ;
20
+ ' dialect' = ' NHibernate.Dialect.MySQL5Dialect'
21
+ };
22
+ ' Odbc' = @ {
23
+ # The OdbcDriver inherits SupportsMultipleOpenReaders=true from DriverBase, which requires Mars_Connection=yes for SQL Server.
24
+ ' connection.connection_string' = ' Server=(local)\SQL2017;Uid=sa;Pwd=Password12!;Database=nhibernateOdbc;Driver={SQL Server Native Client 11.0};Mars_Connection=yes;' ;
25
+ ' connection.driver_class' = ' NHibernate.Driver.OdbcDriver' ;
26
+ ' odbc.explicit_datetime_scale' = ' 3' ;
27
+ <# We need to use a dialect that avoids mapping DbType.Time to TIME on MSSQL. On modern SQL Server
28
+ this becomes TIME(7). Later, such values cannot be read back over ODBC. The
29
+ error we get is "System.ArgumentException : Unknown SQL type - SS_TIME_EX.". I don't know for certain
30
+ why this occurs, but MS docs do say that for a client "compiled using a version of SQL Server Native
31
+ Client prior to SQL Server 2008", TIME(7) cannot be converted back to the client. Assuming that .Net's
32
+ OdbcDriver would be considered a "client compiled with a previous version", it would make sense. Anyway,
33
+ using the MsSql2005Dialect avoids these test failures. #>
34
+ ' dialect' = ' NHibernate.Dialect.MsSql2005Dialect'
35
+ };
36
+ ' PostgreSQL' = @ {
37
+ ' connection.connection_string' = ' Host=localhost;Port=5432;Username=postgres;Password=Password12!;Database=nhibernate;Enlist=true' ;
38
+ ' connection.driver_class' = ' NHibernate.Driver.NpgsqlDriver' ;
39
+ ' dialect' = ' NHibernate.Dialect.PostgreSQL83Dialect'
40
+ };
41
+ ' SQLite' = @ {
42
+ <#
43
+ DateTimeFormatString allows to prevent storing the fact that written date was having kind UTC,
44
+ which dodges the undesirable time conversion to local done on reads by System.Data.SQLite.
45
+ See https://system.data.sqlite.org/index.html/tktview/44a0955ea344a777ffdbcc077831e1adc8b77a36
46
+ and https://github.com/nhibernate/nhibernate-core/issues/1362 #>
47
+ # Please note the connection string is formated for putting the db file in $configDir.
48
+ ' connection.connection_string' = " Data Source=$configDir /NHibernate.db;DateTimeFormatString=yyyy-MM-dd HH:mm:ss.FFFFFFF;" ;
49
+ ' connection.driver_class' = ' NHibernate.Driver.SQLite20Driver' ;
50
+ ' dialect' = ' NHibernate.Dialect.SQLiteDialect'
51
+ };
52
+ ' SqlServerCe' = @ {
53
+ # Please note the connection string is formated for putting the db file in $configDir.
54
+ ' connection.connection_string' = " Data Source=$configDir /NHibernate.sdf;" ;
55
+ ' connection.driver_class' = ' NHibernate.Driver.SqlServerCeDriver' ;
56
+ ' command_timeout' = ' 0' ;
57
+ ' dialect' = ' NHibernate.Dialect.MsSqlCe40Dialect'
58
+ };
59
+ ' SqlServer2008' = @ {
60
+ ' connection.connection_string' = ' Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;'
61
+ };
62
+ ' SqlServer2012' = @ {
63
+ ' connection.connection_string' = ' Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;' ;
64
+ ' dialect' = ' NHibernate.Dialect.MsSql2012Dialect'
65
+ }
66
+ }
67
+ # Settings for current build
68
+ $settings = $allSettings [$Database ]
69
+
70
+ if (! $settings ) {
71
+ Write-Warning " Unable to find $Database settings"
72
+ exit 1
73
+ }
74
+ if (-not [String ]::IsNullOrWhitespace($ConnectionString )) {
75
+ $settings [' connection.connection_string' ] = $ConnectionString
76
+ }
77
+ # Create settings file
78
+ $configFile = (Join-Path $configDir ' hibernate.cfg.xml' )
79
+ New-Item $configDir - Type Directory
80
+ Copy-Item " $ ( [IO.Path ]::Combine(' .' , ' build-common' , ' teamcity-hibernate.cfg.xml' )) " $configFile
81
+ # Patch settings file
82
+ $config = [Xml ] (Get-Content $configFile )
83
+ $allProps = $config .' hibernate-configuration' .' session-factory' .property
84
+ foreach ($key in $settings.keys )
85
+ {
86
+ $value = $settings [$key ]
87
+ $property = $allProps | Where-Object { $_.name -eq $key }
88
+ if (! $property ) {
89
+ Write-Warning " Unable to find $key property"
90
+ exit 1
91
+ }
92
+ $property.InnerText = $value
93
+ }
94
+ $config.Save ($configFile )
95
+ }
96
+
97
+ Task Build {
98
+ Exec {
99
+ dotnet `
100
+ build ./ src/ NHibernate.sln `
101
+ -f netcoreapp2.0 `
102
+ - c Release
103
+ }
104
+ }
105
+
106
+ Task Test - depends Build {
107
+ @ (
108
+ ' NHibernate.TestDatabaseSetup' ,
109
+ ' NHibernate.Test' ,
110
+ ' NHibernate.Test.VisualBasic'
111
+ ) | ForEach-Object {
112
+ $assembly = [IO.Path ]::Combine(" src" , $_ , " bin" , " Release" , " netcoreapp2.0" , " $_ .dll" )
113
+ Exec {
114
+ dotnet $assembly -- labels= before -- nocolor " --result=$_ -TestResult.xml"
115
+ }
116
+ }
117
+ }
0 commit comments