1717using Microsoft . Extensions . Logging ;
1818using MongoDB . Bson ;
1919using MongoDB . Bson . TestHelpers ;
20+ using MongoDB . Driver . Core . Configuration ;
2021using MongoDB . TestHelpers . XunitExtensions ;
2122using MongoDB . Driver . Core . Events ;
2223using MongoDB . Driver . Core . Logging ;
@@ -56,7 +57,8 @@ public void ShouldRedactCommand_should_return_expected_result(string commandJson
5657 public void ShouldTrackState_should_be_correct (
5758 [ Values ( false , true ) ] bool logCommands ,
5859 [ Values ( false , true ) ] bool captureCommandSucceeded ,
59- [ Values ( false , true ) ] bool captureCommandFailed )
60+ [ Values ( false , true ) ] bool captureCommandFailed ,
61+ [ Values ( false , true ) ] bool traceCommands )
6062 {
6163 var mockLogger = new Mock < ILogger < LogCategories . Command > > ( ) ;
6264 mockLogger . Setup ( m => m . IsEnabled ( LogLevel . Debug ) ) . Returns ( logCommands ) ;
@@ -74,9 +76,10 @@ public void ShouldTrackState_should_be_correct(
7476 }
7577
7678 var eventLogger = new EventLogger < LogCategories . Command > ( eventCapturer , mockLogger . Object ) ;
77- var commandHelper = new CommandEventHelper ( eventLogger ) ;
79+ var tracingOptions = traceCommands ? new TracingOptions ( ) : new TracingOptions { Disabled = true } ;
80+ var commandHelper = new CommandEventHelper ( eventLogger , tracingOptions ) ;
7881
79- commandHelper . _shouldTrackState ( ) . Should ( ) . Be ( logCommands || captureCommandSucceeded || captureCommandFailed ) ;
82+ commandHelper . _shouldTrackState ( ) . Should ( ) . Be ( logCommands || captureCommandSucceeded || captureCommandFailed || traceCommands ) ;
8083 }
8184 }
8285
0 commit comments