File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -377,6 +377,49 @@ public void MaxLinesTest()
377377 }
378378 }
379379
380+ [ Fact ]
381+ [ LogManagerReset ]
382+ public void BatchWriteTest ( )
383+ {
384+ try
385+ {
386+ RichTextBoxTarget target = new RichTextBoxTarget ( )
387+ {
388+ ControlName = "Control1" ,
389+ Layout = "${message}" ,
390+ ToolWindow = false ,
391+ AutoScroll = true ,
392+ } ;
393+
394+ Assert . Equal ( 0 , target . MaxLines ) ;
395+ target . MaxLines = 7 ;
396+
397+ ManualResetEvent manualResetEvent = new ManualResetEvent ( false ) ;
398+
399+ var form = target . TargetForm ;
400+ NLog . LogManager . Setup ( ) . LoadConfiguration ( cfg => cfg . ForLogger ( ) . WriteTo ( target ) . WithBuffering ( ) ) ;
401+ ThreadPool . QueueUserWorkItem ( _ =>
402+ {
403+ for ( int i = 0 ; i < 100 ; ++ i )
404+ {
405+ logger . Info ( "Test {0}" , i ) ;
406+ }
407+ NLog . LogManager . Flush ( ) ;
408+ manualResetEvent . Set ( ) ;
409+ } ) ;
410+ manualResetEvent . WaitOne ( 10000 ) ;
411+
412+ Application . DoEvents ( ) ;
413+ string expectedText = "Test 93\n Test 94\n Test 95\n Test 96\n Test 97\n Test 98\n Test 99\n " ;
414+
415+ Assert . Equal ( expectedText , target . TargetRichTextBox . Text ) ;
416+ }
417+ finally
418+ {
419+ LogManager . Configuration = null ;
420+ }
421+ }
422+
380423 [ Fact ]
381424 [ LogManagerReset ]
382425 public void ColoringRuleDefaults ( )
You can’t perform that action at this time.
0 commit comments