11using System ;
22using System . Configuration ;
3+ using System . Diagnostics ;
34using System . Linq ;
45using Migrator . Providers ;
5-
6+ using Migrator . Tests . Settings ;
7+ using Migrator . Tests . Settings . Config ;
8+ using Npgsql ;
69using NUnit . Framework ;
710
811namespace Migrator . Tests ;
@@ -21,57 +24,78 @@ public void CanGetDialectsForProvider()
2124 Assert . That ( ProviderFactory . DialectForProvider ( ProviderTypes . none ) , Is . Null ) ;
2225 }
2326
24- //[Test]
25- //[Category("MySql")]
26- //public void CanLoad_MySqlProvider()
27- //{
28- // using var provider = ProviderFactory.Create(ProviderTypes.Mysql, ConfigurationManager.AppSettings["MySqlConnectionString"], null);
29-
30- // Assert.That(provider, Is.Not.Null);
31- //}
32-
33- //[Test]
34- //[Category("Oracle")]
35- //public void CanLoad_OracleProvider()
36- //{
37- // using var provider = ProviderFactory.Create(ProviderTypes.Oracle, ConfigurationManager.AppSettings["OracleConnectionString"], null);
38-
39- // Assert.That(provider, Is.Not.Null);
40- //}
41-
42- //[Test]
43- //[Category("Postgre")]
44- //public void CanLoad_PostgreSQLProvider()
45- //{
46- // using var provider = ProviderFactory.Create(ProviderTypes.PostgreSQL, ConfigurationManager.AppSettings["NpgsqlConnectionString"], null);
47-
48- // Assert.That(provider, Is.Not.Null);
49- //}
50-
51- //[Test]
52- //[Category("SQLite")]
53- //public void CanLoad_SQLiteProvider()
54- //{
55- // using var provider = ProviderFactory.Create(ProviderTypes.SQLite, ConfigurationManager.AppSettings["SQLiteConnectionString"], null);
27+ [ SetUp ]
28+ public void SetUp ( )
29+ {
30+ DbProviderFactories . RegisterFactory ( "Npgsql" , ( ) => NpgsqlFactory . Instance ) ;
31+ DbProviderFactories . RegisterFactory ( "MySql.Data.MySqlClient" , ( ) => MySql . Data . MySqlClient . MySqlClientFactory . Instance ) ;
32+ DbProviderFactories . RegisterFactory ( "Oracle.DataAccess.Client" , ( ) => Oracle . ManagedDataAccess . Client . OracleClientFactory . Instance ) ;
33+ DbProviderFactories . RegisterFactory ( "System.Data.SqlClient" , ( ) => Microsoft . Data . SqlClient . SqlClientFactory . Instance ) ;
34+ DbProviderFactories . RegisterFactory ( "System.Data.SQLite" , ( ) => System . Data . SQLite . SQLiteFactory . Instance ) ;
35+ }
5636
57- // Assert.That(provider, Is.Not.Null);
58- //}
37+ [ Test ]
38+ [ Category ( "MySql" ) ]
39+ public void CanLoad_MySqlProvider ( )
40+ {
41+ var configReader = new ConfigurationReader ( ) ;
42+ var connectionString = configReader . GetDatabaseConnectionConfigById ( DatabaseConnectionConfigIds . MySQL ) ? . ConnectionString ;
43+ if ( ! String . IsNullOrEmpty ( connectionString ) )
44+ {
45+ using var provider = ProviderFactory . Create ( ProviderTypes . Mysql , connectionString , null ) ;
46+ Assert . That ( provider , Is . Not . Null ) ;
47+ }
48+ }
5949
60- //[Test]
61- //[Category("SqlServer2005")]
62- //public void CanLoad_SqlServer2005Provider()
63- //{
64- // using var provider = ProviderFactory.Create(ProviderTypes.SqlServer2005, ConfigurationManager.AppSettings["SqlServer2005ConnectionString"], null);
50+ [ Test ]
51+ [ Category ( "Oracle" ) ]
52+ public void CanLoad_OracleProvider ( )
53+ {
54+ var configReader = new ConfigurationReader ( ) ;
55+ var connectionString = configReader . GetDatabaseConnectionConfigById ( DatabaseConnectionConfigIds . Oracle ) ? . ConnectionString ;
56+ if ( ! String . IsNullOrEmpty ( connectionString ) )
57+ {
58+ using var provider = ProviderFactory . Create ( ProviderTypes . Oracle , connectionString , null ) ;
59+ Assert . That ( provider , Is . Not . Null ) ;
60+ }
61+ }
6562
66- // Assert.That(provider, Is.Not.Null);
67- //}
63+ [ Test ]
64+ [ Category ( "Postgre" ) ]
65+ public void CanLoad_PostgreSQLProvider ( )
66+ {
67+ var configReader = new ConfigurationReader ( ) ;
68+ var connectionString = configReader . GetDatabaseConnectionConfigById ( DatabaseConnectionConfigIds . PostgreSQL ) ? . ConnectionString ;
69+ if ( ! String . IsNullOrEmpty ( connectionString ) )
70+ {
71+ using var provider = ProviderFactory . Create ( ProviderTypes . PostgreSQL , connectionString , null ) ;
72+ Assert . That ( provider , Is . Not . Null ) ;
73+ }
74+ }
6875
69- //[Test]
70- //[Category("SqlServer")]
71- //public void CanLoad_SqlServerProvider()
72- //{
73- // using var provider = ProviderFactory.Create(ProviderTypes.SqlServer, ConfigurationManager.AppSettings["SqlServerConnectionString"], null);
76+ [ Test ]
77+ [ Category ( "SQLite" ) ]
78+ public void CanLoad_SQLiteProvider ( )
79+ {
80+ var configReader = new ConfigurationReader ( ) ;
81+ var connectionString = configReader . GetDatabaseConnectionConfigById ( DatabaseConnectionConfigIds . SQLiteConnectionConfigId ) ? . ConnectionString ;
82+ if ( ! String . IsNullOrEmpty ( connectionString ) )
83+ {
84+ using var provider = ProviderFactory . Create ( ProviderTypes . SQLite , connectionString , null ) ;
85+ Assert . That ( provider , Is . Not . Null ) ;
86+ }
87+ }
7488
75- // Assert.That(provider, Is.Not.Null);
76- //}
89+ [ Test ]
90+ [ Category ( "SqlServer" ) ]
91+ public void CanLoad_SqlServerProvider ( )
92+ {
93+ var configReader = new ConfigurationReader ( ) ;
94+ var connectionString = configReader . GetDatabaseConnectionConfigById ( DatabaseConnectionConfigIds . SQLServerConnectionConfigId ) ? . ConnectionString ;
95+ if ( ! String . IsNullOrEmpty ( connectionString ) )
96+ {
97+ using var provider = ProviderFactory . Create ( ProviderTypes . SqlServer , connectionString , null ) ;
98+ Assert . That ( provider , Is . Not . Null ) ;
99+ }
100+ }
77101}
0 commit comments