11namespace ServiceControl . Audit . Persistence . Tests ;
22
3- using System ;
3+ using System . Threading ;
44using System . Threading . Tasks ;
5- using global ::ServiceControl . Audit . Persistence . RavenDB ;
65using NUnit . Framework ;
6+ using Persistence . RavenDB ;
7+ using Persistence . RavenDB . Indexes ;
78using Raven . Client . Documents . Indexes ;
89using Raven . Client . Documents . Operations . Indexes ;
910
1011[ TestFixture ]
1112class IndexSetupTests : PersistenceTestFixture
1213{
1314 [ Test ]
14- public async Task Corax_should_the_defaul_search_engine_type ( )
15+ public async Task Corax_should_be_the_default_search_engine_type ( )
1516 {
1617 var indexes = await configuration . DocumentStore . Maintenance . SendAsync ( new GetIndexesOperation ( 0 , int . MaxValue ) ) ;
1718
@@ -31,4 +32,27 @@ public async Task Free_text_search_index_should_be_used_by_default()
3132 Assert . That ( nonFreeTextIndex , Is . Null ) ;
3233 Assert . That ( freeTextIndex , Is . Not . Null ) ;
3334 }
35+
36+ [ Test ]
37+ public async Task Indexes_should_be_reset_on_setup ( )
38+ {
39+ var index = new MessagesViewIndexWithFullTextSearch { Configuration = { [ "Indexing.Static.SearchEngineType" ] = SearchEngineType . Lucene . ToString ( ) } } ;
40+
41+ await IndexCreation . CreateIndexesAsync ( [ index ] , configuration . DocumentStore ) ;
42+
43+ //TODO: find a better way
44+ await Task . Delay ( 1000 ) ;
45+
46+ var indexStatsBefore = await configuration . DocumentStore . Maintenance . SendAsync ( new GetIndexStatisticsOperation ( index . IndexName ) ) ;
47+
48+ Assert . That ( indexStatsBefore . SearchEngineType , Is . EqualTo ( SearchEngineType . Lucene ) ) ;
49+
50+ await DatabaseSetup . CreateIndexes ( configuration . DocumentStore , true , CancellationToken . None ) ;
51+
52+ //TODO: find a better way
53+ await Task . Delay ( 1000 ) ;
54+
55+ var indexStatsAfter = await configuration . DocumentStore . Maintenance . SendAsync ( new GetIndexStatisticsOperation ( index . IndexName ) ) ;
56+ Assert . That ( indexStatsAfter . SearchEngineType , Is . EqualTo ( SearchEngineType . Corax ) ) ;
57+ }
3458}
0 commit comments