@@ -26,6 +26,7 @@ namespace CDP4Dal.Tests
2626{
2727 using System ;
2828 using System . Collections . Generic ;
29+ using System . Diagnostics ;
2930 using System . Linq ;
3031 using System . Threading . Tasks ;
3132
@@ -191,6 +192,59 @@ public async Task AssertThatAssemblerSynchronizationWorks()
191192 Assert . That ( assembler . Cache . TryGetValue ( new CacheKey ( categoryToRemove . Iid , null ) , out lazyCat ) , Is . False ) ;
192193 }
193194
195+ [ Test ]
196+ public async Task AssertThatAssemblerSynchronizationWorksFastEnough ( )
197+ {
198+ var assembler = new Assembler ( this . uri , this . messageBus ) ;
199+
200+ var domain = new Dto . DomainOfExpertise ( Guid . NewGuid ( ) , 1 ) ;
201+ this . testInput . Add ( domain ) ;
202+
203+ for ( var i = 0 ; i < 20000 ; i ++ )
204+ {
205+ this . testInput . Add ( new Dto . ElementDefinition ( Guid . NewGuid ( ) , 1 ) { Owner = domain . Iid } ) ;
206+ }
207+
208+ var sw = new Stopwatch ( ) ;
209+
210+ sw . Reset ( ) ;
211+ sw . Start ( ) ;
212+
213+ // 1st call of Synnchronize
214+ await assembler . Synchronize ( this . testInput ) ;
215+
216+ sw . Stop ( ) ;
217+ var elapsed = sw . Elapsed ;
218+ await TestContext . Progress . WriteLineAsync ( $ "First synchronize took { elapsed } ") ;
219+ // Modification of the input Dtos
220+ Assert . That ( assembler . Cache , Is . Not . Empty ) ;
221+ Assert . That ( this . testInput . Count , Is . EqualTo ( assembler . Cache . Count ) ) ;
222+
223+ sw . Reset ( ) ;
224+ sw . Start ( ) ;
225+
226+ // 1st call of Synnchronize
227+ await assembler . Synchronize ( this . testInput ) ;
228+
229+ sw . Stop ( ) ;
230+ elapsed = sw . Elapsed ;
231+ await TestContext . Progress . WriteLineAsync ( $ "Second synchronize took { elapsed } ") ;
232+ Assert . That ( assembler . Cache , Is . Not . Empty ) ;
233+ Assert . That ( this . testInput . Count , Is . EqualTo ( assembler . Cache . Count ) ) ;
234+
235+ sw . Reset ( ) ;
236+ sw . Start ( ) ;
237+
238+ // 1st call of Synnchronize
239+ await assembler . Synchronize ( this . testInput ) ;
240+
241+ sw . Stop ( ) ;
242+ elapsed = sw . Elapsed ;
243+ await TestContext . Progress . WriteLineAsync ( $ "Third synchronize took { elapsed } ") ;
244+ Assert . That ( assembler . Cache , Is . Not . Empty ) ;
245+ Assert . That ( this . testInput . Count , Is . EqualTo ( assembler . Cache . Count ) ) ;
246+ }
247+
194248 [ Test ]
195249 public async Task AssertThatRevisionsAreCachedCorrectly ( )
196250 {
0 commit comments