@@ -135,6 +135,64 @@ public async Task CanCreateAndDropSchema(bool isDatabaseMissing)
135135 Assert . DoesNotContain ( "dt" , testDb . GetSchemas ( ) ) ;
136136 }
137137
138+ /// <summary>
139+ /// Verifies that the schema can be created and dropped correctly when using
140+ /// a case-sensitive database collation (SQL_Latin1_General_CP1_CS_AS).
141+ /// This helps prevent case-sensitivity regressions (see issue #111).
142+ /// </summary>
143+ [ Fact ]
144+ public async Task CanCreateAndDropSchemaWithCaseSensitiveCollation ( )
145+ {
146+ using TestDatabase testDb = this . CreateTestDb (
147+ initializeDatabase : true ,
148+ collation : "SQL_Latin1_General_CP1_CS_AS" ) ;
149+ IOrchestrationService service = this . CreateServiceWithTestDb ( testDb ) ;
150+
151+ // Create the DB schema for the first time
152+ await service . CreateAsync ( recreateInstanceStore : true ) ;
153+
154+ LogAssert . NoWarningsOrErrors ( this . logProvider ) ;
155+ LogAssert
156+ . For ( this . logProvider )
157+ . Expect (
158+ LogAssert . CheckedDatabase ( ) )
159+ . Expect (
160+ LogAssert . AcquiredAppLock ( ) ,
161+ LogAssert . ExecutedSqlScript ( "drop-schema.sql" ) ,
162+ LogAssert . ExecutedSqlScript ( "schema-1.0.0.sql" ) ,
163+ LogAssert . ExecutedSqlScript ( "schema-1.2.0.sql" ) ,
164+ LogAssert . ExecutedSqlScript ( "schema-1.6.0.sql" ) ,
165+ LogAssert . ExecutedSqlScript ( "logic.sql" ) ,
166+ LogAssert . ExecutedSqlScript ( "permissions.sql" ) ,
167+ LogAssert . SprocCompleted ( "dt._UpdateVersion" ) )
168+ . EndOfLog ( ) ;
169+
170+ await this . ValidateDatabaseSchemaAsync ( testDb ) ;
171+
172+ // Create the DB schema again - should be a no-op since it already exists
173+ this . logProvider . Clear ( ) ;
174+ await service . CreateIfNotExistsAsync ( ) ;
175+ await this . ValidateDatabaseSchemaAsync ( testDb ) ;
176+
177+ LogAssert . NoWarningsOrErrors ( this . logProvider ) ;
178+ LogAssert . Sequence (
179+ this . logProvider ,
180+ LogAssert . CheckedDatabase ( ) ,
181+ LogAssert . AcquiredAppLock ( ) ,
182+ LogAssert . SprocCompleted ( "dt._GetVersions" ) ) ;
183+
184+ // Delete the database and validate
185+ this . logProvider . Clear ( ) ;
186+ await service . DeleteAsync ( ) ;
187+ LogAssert . NoWarningsOrErrors ( this . logProvider ) ;
188+ LogAssert . Sequence (
189+ this . logProvider ,
190+ LogAssert . AcquiredAppLock ( ) ,
191+ LogAssert . ExecutedSqlScript ( "drop-schema.sql" ) ) ;
192+
193+ Assert . DoesNotContain ( "dt" , testDb . GetSchemas ( ) ) ;
194+ }
195+
138196 [ Theory ]
139197 [ InlineData ( true ) ]
140198 [ InlineData ( false ) ]
@@ -411,9 +469,9 @@ public async Task SchemaUpgradeAddsTagsColumn()
411469 Assert . Contains ( "Tags" , taskColumns ) ;
412470 }
413471
414- TestDatabase CreateTestDb ( bool initializeDatabase = true )
472+ TestDatabase CreateTestDb ( bool initializeDatabase = true , string collation = "Latin1_General_100_BIN2_UTF8" )
415473 {
416- var testDb = new TestDatabase ( this . output ) ;
474+ var testDb = new TestDatabase ( this . output , collation ) ;
417475 if ( initializeDatabase )
418476 {
419477 testDb . Create ( ) ;
@@ -545,13 +603,13 @@ sealed class TestDatabase : IDisposable
545603 readonly ITestOutputHelper output ;
546604 bool created = false ;
547605
548- public TestDatabase ( ITestOutputHelper output )
606+ public TestDatabase ( ITestOutputHelper output , string collation = "Latin1_General_100_BIN2_UTF8" )
549607 {
550608 string defaultConnectionString = SharedTestHelpers . GetDefaultConnectionString ( "master" ) ;
551609 this . server = new Server ( new ServerConnection ( new SqlConnection ( defaultConnectionString ) ) ) ;
552610 this . testDb = new Database ( this . server , $ "TestDB_{ DateTime . UtcNow : yyyyMMddhhmmssfffffff} ")
553611 {
554- Collation = "Latin1_General_100_BIN2_UTF8"
612+ Collation = collation
555613 } ;
556614
557615 this . ConnectionString =
0 commit comments