public void End_WithDisposedTimedScope_ShouldLogError() { FailOnErrors = false; Mock <ITimedScopeLogger> timedScopeLoggerMock = new Mock <ITimedScopeLogger>(); Mock <IReplayEventConfigurator> replyEventConfiguratorMock = new Mock <IReplayEventConfigurator>(); Mock <ICallContextManager> callContextManagerMock = new Mock <ICallContextManager>(); IMachineInformation machineInformation = new UnitTestMachineInformation(); ITimedScopeStackManager timedScopeStackManager = new TimedScopeStackManager(callContextManagerMock.Object, machineInformation); using (TimedScope scope = TestHooks.CreateDefaultTimedScope(timedScopeLoggerMock.Object, replyEventConfiguratorMock.Object, machineInformation, timedScopeStackManager)) { Assert.True(scope.IsScopeActive, "Timer should be active."); scope.Dispose(); Assert.False(scope.IsScopeActive, "Dispose should turn off timer."); scope.End(); Assert.Equal(TraceErrors.Count(), 1); LoggedEvents.Clear(); } }
public void AddLoggingValue_WithNullKey_ShouldLogError() { FailOnErrors = false; Mock <ITimedScopeLogger> timedScopeLoggerMock = new Mock <ITimedScopeLogger>(); Mock <IReplayEventConfigurator> replyEventConfiguratorMock = new Mock <IReplayEventConfigurator>(); Mock <ICallContextManager> callContextManagerMock = new Mock <ICallContextManager>(); IMachineInformation machineInformation = new UnitTestMachineInformation(); ITimedScopeStackManager timedScopeStackManager = new TimedScopeStackManager(callContextManagerMock.Object, machineInformation); using (TimedScope scope = TestHooks.CreateDefaultTimedScope(timedScopeLoggerMock.Object, replyEventConfiguratorMock.Object, machineInformation, timedScopeStackManager)) { scope.AddLoggingValue(null, "My Application."); Assert.Equal(TraceErrors.Count(), 1); LoggedEvents.Clear(); } }
public void Start_DisposedTimedScope_ShoudLogError() { FailOnErrors = false; Mock <ITimedScopeLogger> timedScopeLoggerMock = new Mock <ITimedScopeLogger>(); Mock <IReplayEventConfigurator> replyEventConfiguratorMock = new Mock <IReplayEventConfigurator>(); Mock <ICallContextManager> callContextManagerMock = new Mock <ICallContextManager>(); IMachineInformation machineInformation = new UnitTestMachineInformation(); ITimedScopeStackManager timedScopeStackManager = new TimedScopeStackManager(callContextManagerMock.Object, machineInformation); TimedScope scope = TestHooks.CreateDefaultTimedScope(timedScopeLoggerMock.Object, replyEventConfiguratorMock.Object, machineInformation, timedScopeStackManager); scope.Dispose(); scope.Start(); Assert.Equal(TraceErrors.Count(), 1); LoggedEvents.Clear(); }