44 using System . Threading ;
55 using System . Threading . Tasks ;
66 using NUnit . Framework ;
7+ using Persistence . RavenDB ;
78 using Raven . Client . Documents . Indexes ;
89 using Raven . Client . Documents . Operations . Indexes ;
910 using ServiceControl . SagaAudit ;
@@ -14,14 +15,14 @@ class SagaDetailsIndexTests : PersistenceTestFixture
1415 [ Test ]
1516 public async Task Deletes_index_that_does_not_have_cap_of_50000 ( )
1617 {
17- await configuration . DocumentStore . Maintenance . SendAsync ( new DeleteIndexOperation ( "SagaDetailsIndex" ) ) ;
18+ await configuration . DocumentStore . Maintenance . SendAsync ( new DeleteIndexOperation ( DatabaseSetup . SagaDetailsIndexName ) ) ;
1819
1920 var indexWithout50000capDefinition = new IndexDefinition
2021 {
21- Name = "SagaDetailsIndex" ,
22+ Name = DatabaseSetup . SagaDetailsIndexName ,
2223 Maps =
23- [
24- @"from doc in docs
24+ [
25+ @"from doc in docs
2526 select new
2627 {
2728 doc.SagaId,
@@ -41,7 +42,7 @@ public async Task Deletes_index_that_does_not_have_cap_of_50000()
4142 }
4243 }
4344 }"
44- ] ,
45+ ] ,
4546 Reduce = @"from result in results
4647 group result by result.SagaId
4748 into g
@@ -61,12 +62,12 @@ into g
6162
6263 await configuration . DocumentStore . Maintenance . SendAsync ( putIndexesOp ) ;
6364
64- var sagaDetailsIndexOperation = new GetIndexOperation ( "SagaDetailsIndex" ) ;
65+ var sagaDetailsIndexOperation = new GetIndexOperation ( DatabaseSetup . SagaDetailsIndexName ) ;
6566 var sagaDetailsIndexDefinition = await configuration . DocumentStore . Maintenance . SendAsync ( sagaDetailsIndexOperation ) ;
6667
6768 Assert . That ( sagaDetailsIndexDefinition , Is . Not . Null ) ;
6869
69- await Persistence . RavenDB . DatabaseSetup . DeleteLegacySagaDetailsIndex ( configuration . DocumentStore , CancellationToken . None ) ;
70+ await DatabaseSetup . DeleteLegacySagaDetailsIndex ( configuration . DocumentStore , CancellationToken . None ) ;
7071
7172 sagaDetailsIndexDefinition = await configuration . DocumentStore . Maintenance . SendAsync ( sagaDetailsIndexOperation ) ;
7273
7677 [ Test ]
7778 public async Task Does_not_delete_index_that_does_have_cap_of_50000 ( )
7879 {
79- await Persistence . RavenDB . DatabaseSetup . DeleteLegacySagaDetailsIndex ( configuration . DocumentStore , CancellationToken . None ) ;
80+ await DatabaseSetup . DeleteLegacySagaDetailsIndex ( configuration . DocumentStore , CancellationToken . None ) ;
8081
81- var sagaDetailsIndexOperation = new GetIndexOperation ( "SagaDetailsIndex" ) ;
82+ var sagaDetailsIndexOperation = new GetIndexOperation ( DatabaseSetup . SagaDetailsIndexName ) ;
8283 var sagaDetailsIndexDefinition = await configuration . DocumentStore . Maintenance . SendAsync ( sagaDetailsIndexOperation ) ;
8384
8485 Assert . That ( sagaDetailsIndexDefinition , Is . Not . Null ) ;
@@ -100,13 +101,10 @@ await IngestSagaAudits(new SagaSnapshot
100101
101102 await configuration . CompleteDBOperation ( ) ;
102103
103- using ( var session = configuration . DocumentStore . OpenAsyncSession ( ) )
104- {
105- var sagaDetailsIndexOperation = new GetIndexOperation ( "SagaDetailsIndex" ) ;
106- var sagaDetailsIndexDefinition = await configuration . DocumentStore . Maintenance . SendAsync ( sagaDetailsIndexOperation ) ;
104+ var sagaDetailsIndexOperation = new GetIndexOperation ( DatabaseSetup . SagaDetailsIndexName ) ;
105+ var sagaDetailsIndexDefinition = await configuration . DocumentStore . Maintenance . SendAsync ( sagaDetailsIndexOperation ) ;
107106
108- Assert . That ( sagaDetailsIndexDefinition . Reduce , Does . Contain ( "Take(50000)" ) , "The SagaDetails index definition does not contain a .Take(50000) to limit the number of saga state changes that are reduced by the map/reduce" ) ;
109- }
107+ Assert . That ( sagaDetailsIndexDefinition . Reduce , Does . Contain ( "Take(50000)" ) , "The SagaDetails index definition does not contain a .Take(50000) to limit the number of saga state changes that are reduced by the map/reduce" ) ;
110108 }
111109
112110 async Task IngestSagaAudits ( params SagaSnapshot [ ] snapshots )
@@ -116,6 +114,7 @@ async Task IngestSagaAudits(params SagaSnapshot[] snapshots)
116114 {
117115 await unitOfWork . RecordSagaSnapshot ( snapshot ) ;
118116 }
117+
119118 await unitOfWork . DisposeAsync ( ) ;
120119 await configuration . CompleteDBOperation ( ) ;
121120 }
0 commit comments