File tree Expand file tree Collapse file tree 4 files changed +54
-0
lines changed
Statement/ColumnConstraint
Internal/Statement/ColumnConstraint Expand file tree Collapse file tree 4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 8080 <Compile Include =" Statement\ColumnConstraint\MaxLengthConstraint.cs" />
8181 <Compile Include =" Statement\ColumnConstraint\ColumnConstraintCollectionTest.cs" />
8282 <Compile Include =" Statement\ColumnConstraint\NotNullConstraintTest.cs" />
83+ <Compile Include =" Statement\ColumnConstraint\CollateConstraintTest.cs" />
8384 <Compile Include =" Statement\ColumnConstraint\UniqueConstraintTest.cs" />
8485 <Compile Include =" Statement\ColumnStatementCollectionTest.cs" />
8586 <Compile Include =" Statement\PrimaryKeyStatementTest.cs" />
Original file line number Diff line number Diff line change 1+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
2+ using SQLite . CodeFirst . Statement . ColumnConstraint ;
3+
4+ namespace SQLite . CodeFirst . Test . Statement . ColumnConstraint
5+ {
6+ [ TestClass ]
7+ public class CollateConstraintTest
8+ {
9+ [ TestMethod ]
10+ public void CreateStatement_StatementIsCorrect_NoConstraint ( )
11+ {
12+ var collationConstraint = new CollateConstraint ( ) ;
13+ collationConstraint . CollationFunction = CollationFunction . None ;
14+ string output = collationConstraint . CreateStatement ( ) ;
15+ Assert . AreEqual ( output , "" ) ;
16+ }
17+
18+ [ TestMethod ]
19+ public void CreateStatement_StatementIsCorrect_NoCase ( )
20+ {
21+ var collationConstraint = new CollateConstraint ( ) ;
22+ collationConstraint . CollationFunction = CollationFunction . NoCase ;
23+ string output = collationConstraint . CreateStatement ( ) ;
24+ Assert . AreEqual ( output , "COLLATE NOCASE" ) ;
25+ }
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ using System . Text ;
2+
3+ namespace SQLite . CodeFirst . Statement . ColumnConstraint
4+ {
5+ internal class CollateConstraint : IColumnConstraint
6+ {
7+ private const string Template = "COLLATE {collation-name}" ;
8+
9+ public CollationFunction CollationFunction { get ; set ; }
10+
11+ public string CreateStatement ( )
12+ {
13+ if ( CollationFunction == CollationFunction . None )
14+ {
15+ return string . Empty ;
16+ }
17+
18+ var sb = new StringBuilder ( Template ) ;
19+
20+ sb . Replace ( "{collation-name}" , CollationFunction . ToString ( ) . ToUpperInvariant ( ) ) ;
21+
22+ return sb . ToString ( ) . Trim ( ) ;
23+ }
24+ }
25+ }
Original file line number Diff line number Diff line change 9191 <Compile Include =" Internal\Builder\NameCreators\IndexNameCreator.cs" />
9292 <Compile Include =" Internal\Builder\NameCreators\SpecialChars.cs" />
9393 <Compile Include =" IDatabaseCreator.cs" />
94+ <Compile Include =" Internal\Statement\ColumnConstraint\CollateConstraint.cs" />
9495 <Compile Include =" Internal\Statement\ColumnConstraint\UniqueConstraint.cs" />
9596 <Compile Include =" Internal\Utility\HashCreator.cs" />
9697 <Compile Include =" Internal\Utility\HistoryEntityTypeValidator.cs" />
You can’t perform that action at this time.
0 commit comments