77using Migrator . Providers . SqlServer ;
88using NUnit . Framework ;
99
10- namespace Migrator . Tests
10+ namespace Migrator . Tests ;
11+
12+ [ TestFixture ]
13+ public class ColumnPropertyMapperTest
1114{
12- [ TestFixture ]
13- public class ColumnPropertyMapperTest
15+ [ Test ]
16+ public void OracleCreatesNotNullSql ( )
1417 {
15- [ Test ]
16- public void OracleCreatesNotNullSql ( )
17- {
18- var mapper = new ColumnPropertiesMapper ( new OracleDialect ( ) , "varchar(30)" ) ;
19- mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , ColumnProperty . NotNull ) ) ;
20- Assert . That ( "foo varchar(30) NOT NULL" , Is . EqualTo ( mapper . ColumnSql ) ) ;
21- }
18+ var mapper = new ColumnPropertiesMapper ( new OracleDialect ( ) , "varchar(30)" ) ;
19+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , ColumnProperty . NotNull ) ) ;
20+ Assert . That ( "foo varchar(30) NOT NULL" , Is . EqualTo ( mapper . ColumnSql ) ) ;
21+ }
2222
23- [ Test ]
24- public void OracleCreatesSql ( )
25- {
26- var mapper = new ColumnPropertiesMapper ( new OracleDialect ( ) , "varchar(30)" ) ;
27- mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 0 ) ) ;
28- Assert . That ( "foo varchar(30)" , Is . EqualTo ( mapper . ColumnSql ) ) ;
29- }
23+ [ Test ]
24+ public void OracleCreatesSql ( )
25+ {
26+ var mapper = new ColumnPropertiesMapper ( new OracleDialect ( ) , "varchar(30)" ) ;
27+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 0 ) ) ;
28+ Assert . That ( "foo varchar(30)" , Is . EqualTo ( mapper . ColumnSql ) ) ;
29+ }
3030
31- [ Test ]
32- public void OracleIndexSqlIsNoNullWhenIndexed ( )
33- {
34- var mapper = new ColumnPropertiesMapper ( new OracleDialect ( ) , "char(1)" ) ;
35- mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , ColumnProperty . Indexed ) ) ;
36- Assert . That ( mapper . IndexSql , Is . Not . Null ) ;
37- }
31+ [ Test ]
32+ public void OracleIndexSqlIsNoNullWhenIndexed ( )
33+ {
34+ var mapper = new ColumnPropertiesMapper ( new OracleDialect ( ) , "char(1)" ) ;
35+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , ColumnProperty . Indexed ) ) ;
36+ Assert . That ( mapper . IndexSql , Is . Not . Null ) ;
37+ }
3838
39- [ Test ]
40- public void OracleIndexSqlIsNullWhenIndexedFalse ( )
41- {
42- var mapper = new ColumnPropertiesMapper ( new OracleDialect ( ) , "char(1)" ) ;
43- mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , 0 ) ) ;
44- Assert . That ( mapper . IndexSql , Is . Null ) ;
45- }
39+ [ Test ]
40+ public void OracleIndexSqlIsNullWhenIndexedFalse ( )
41+ {
42+ var mapper = new ColumnPropertiesMapper ( new OracleDialect ( ) , "char(1)" ) ;
43+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , 0 ) ) ;
44+ Assert . That ( mapper . IndexSql , Is . Null ) ;
45+ }
4646
47- [ Test ]
48- public void PostgresIndexSqlIsNoNullWhenIndexed ( )
49- {
50- var mapper = new ColumnPropertiesMapper ( new PostgreSQLDialect ( ) , "char(1)" ) ;
51- mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , ColumnProperty . Indexed ) ) ;
52- Assert . That ( mapper . IndexSql , Is . Not . Null ) ;
53- }
47+ [ Test ]
48+ public void PostgresIndexSqlIsNoNullWhenIndexed ( )
49+ {
50+ var mapper = new ColumnPropertiesMapper ( new PostgreSQLDialect ( ) , "char(1)" ) ;
51+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , ColumnProperty . Indexed ) ) ;
52+ Assert . That ( mapper . IndexSql , Is . Not . Null ) ;
53+ }
5454
55- [ Test ]
56- public void PostgresIndexSqlIsNullWhenIndexedFalse ( )
57- {
58- var mapper = new ColumnPropertiesMapper ( new PostgreSQLDialect ( ) , "char(1)" ) ;
59- mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , 0 ) ) ;
60- Assert . That ( mapper . IndexSql , Is . Null ) ;
61- }
55+ [ Test ]
56+ public void PostgresIndexSqlIsNullWhenIndexedFalse ( )
57+ {
58+ var mapper = new ColumnPropertiesMapper ( new PostgreSQLDialect ( ) , "char(1)" ) ;
59+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , 0 ) ) ;
60+ Assert . That ( mapper . IndexSql , Is . Null ) ;
61+ }
6262
63- [ Test ]
64- public void SqlServerCreatesNotNullSql ( )
65- {
66- var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "varchar(30)" ) ;
67- mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , ColumnProperty . NotNull ) ) ;
68- Assert . That ( "[foo] varchar(30) NOT NULL" , Is . EqualTo ( mapper . ColumnSql ) ) ;
69- }
63+ [ Test ]
64+ public void SqlServerCreatesNotNullSql ( )
65+ {
66+ var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "varchar(30)" ) ;
67+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , ColumnProperty . NotNull ) ) ;
68+ Assert . That ( "[foo] varchar(30) NOT NULL" , Is . EqualTo ( mapper . ColumnSql ) ) ;
69+ }
7070
71- [ Test ]
72- public void SqlServerCreatesSqWithBooleanDefault ( )
73- {
74- var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "bit" ) ;
75- mapper . MapColumnProperties ( new Column ( "foo" , DbType . Boolean , 0 , false ) ) ;
76- Assert . That ( "[foo] bit DEFAULT 0" , Is . EqualTo ( mapper . ColumnSql ) ) ;
71+ [ Test ]
72+ public void SqlServerCreatesSqWithBooleanDefault ( )
73+ {
74+ var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "bit" ) ;
75+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . Boolean , 0 , false ) ) ;
76+ Assert . That ( "[foo] bit DEFAULT 0" , Is . EqualTo ( mapper . ColumnSql ) ) ;
7777
78- mapper . MapColumnProperties ( new Column ( "bar" , DbType . Boolean , 0 , true ) ) ;
79- Assert . That ( "[bar] bit DEFAULT 1" , Is . EqualTo ( mapper . ColumnSql ) ) ;
80- }
78+ mapper . MapColumnProperties ( new Column ( "bar" , DbType . Boolean , 0 , true ) ) ;
79+ Assert . That ( "[bar] bit DEFAULT 1" , Is . EqualTo ( mapper . ColumnSql ) ) ;
80+ }
8181
82- [ Test ]
83- public void SqlServerCreatesSqWithDefault ( )
84- {
85- var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "varchar(30)" ) ;
86- mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 0 , "'NEW'" ) ) ;
87- Assert . That ( "[foo] varchar(30) DEFAULT '''NEW'''" , Is . EqualTo ( mapper . ColumnSql ) ) ;
88- }
82+ [ Test ]
83+ public void SqlServerCreatesSqWithDefault ( )
84+ {
85+ var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "varchar(30)" ) ;
86+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 0 , "'NEW'" ) ) ;
87+ Assert . That ( "[foo] varchar(30) DEFAULT '''NEW'''" , Is . EqualTo ( mapper . ColumnSql ) ) ;
88+ }
8989
90- [ Test ]
91- public void SqlServerCreatesSqWithNullDefault ( )
92- {
93- var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "varchar(30)" ) ;
94- mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 0 , "NULL" ) ) ;
95- Assert . That ( "[foo] varchar(30) DEFAULT 'NULL'" , Is . EqualTo ( mapper . ColumnSql ) ) ;
96- }
90+ [ Test ]
91+ public void SqlServerCreatesSqWithNullDefault ( )
92+ {
93+ var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "varchar(30)" ) ;
94+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 0 , "NULL" ) ) ;
95+ Assert . That ( "[foo] varchar(30) DEFAULT 'NULL'" , Is . EqualTo ( mapper . ColumnSql ) ) ;
96+ }
9797
98- [ Test ]
99- public void SqlServerCreatesSql ( )
100- {
101- var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "varchar(30)" ) ;
102- mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 0 ) ) ;
103- Assert . That ( "[foo] varchar(30)" , Is . EqualTo ( mapper . ColumnSql ) ) ;
104- }
98+ [ Test ]
99+ public void SqlServerCreatesSql ( )
100+ {
101+ var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "varchar(30)" ) ;
102+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 0 ) ) ;
103+ Assert . That ( "[foo] varchar(30)" , Is . EqualTo ( mapper . ColumnSql ) ) ;
104+ }
105105
106- [ Test ]
107- public void SqlServerIndexSqlIsNoNullWhenIndexed ( )
108- {
109- var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "char(1)" ) ;
110- mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , ColumnProperty . Indexed ) ) ;
111- Assert . That ( mapper . IndexSql , Is . Null ) ;
112- }
106+ [ Test ]
107+ public void SqlServerIndexSqlIsNoNullWhenIndexed ( )
108+ {
109+ var mapper = new ColumnPropertiesMapper ( new SqlServerDialect ( ) , "char(1)" ) ;
110+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . StringFixedLength , 1 , ColumnProperty . Indexed ) ) ;
111+ Assert . That ( mapper . IndexSql , Is . Null ) ;
112+ }
113113
114- [ Test ]
115- public void SQLiteIndexSqlWithEmptyStringDefault ( )
116- {
117- var mapper = new ColumnPropertiesMapper ( new SQLiteDialect ( ) , "varchar(30)" ) ;
118- mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 1 , ColumnProperty . NotNull , string . Empty ) ) ;
119- Assert . That ( "foo varchar(30) NOT NULL DEFAULT ''" , Is . EqualTo ( mapper . ColumnSql ) ) ;
120- }
114+ [ Test ]
115+ public void SQLiteIndexSqlWithEmptyStringDefault ( )
116+ {
117+ var mapper = new ColumnPropertiesMapper ( new SQLiteDialect ( ) , "varchar(30)" ) ;
118+ mapper . MapColumnProperties ( new Column ( "foo" , DbType . String , 1 , ColumnProperty . NotNull , string . Empty ) ) ;
119+ Assert . That ( "foo varchar(30) NOT NULL DEFAULT ''" , Is . EqualTo ( mapper . ColumnSql ) ) ;
121120 }
122121}
0 commit comments