public void DefaultTimedScopeResult_LogsAsSystemError() { LoggedEvents.Clear(); CorrelationData data = new CorrelationData(); UnitTestTimedScopeLogger unitTestTimedScopeLogger = new UnitTestTimedScopeLogger(); 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.Create(data, machineInformation, TestHooks.DefaultTimedScopeName, "description", unitTestTimedScopeLogger, replyEventConfiguratorMock.Object, timedScopeStackManager, default(TimedScopeResult))) { } TimedScopeLogEvent evt = unitTestTimedScopeLogger.SingleTimedScopeEvent(TestHooks.DefaultTimedScopeName); if (VerifyNotNullAndReturn(evt, "A scope event has been logged")) { Assert.Equal(TimedScopeResult.SystemError, evt.Result); } }
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(); } }
private void Clear(object sender, RoutedEventArgs e) { LoggedEvents.Clear(); if (_mw == null) { return; } _mw.UpdateLoggerCounts(); }
public void ClearCollections() { LoggedEvents.Clear(); LoggedMetricEvents.Clear(); MetricEventsBegan.Clear(); EventsBegan.Clear(); MetricEventsEnded.Clear(); EventsEnded.Clear(); }
public void GetUserGroups_TestGroupsDataSetIsNull_ReturnsEmptyListAndLogs() { FailOnErrors = false; using (IConfigurationDataSetLoader <TestGroupsDataSet> loader = new UnitTestDataSetLoader <TestGroupsDataSet>(new LocalCache(), new UnitTestResourceMonitor())) { TestGroups testGroups = new TestGroups(loader); LoggedEvents.Clear(); Assert.False(testGroups.GetUserGroups("*****@*****.**").Any(), "Returns empty list if currently loaded TestGroupsDataSet is null"); IEnumerable <LogEventArgs> events = LoggedEvents; Assert.NotNull(events); Assert.Equal(1, events.Count(e => e.Level == Levels.Error)); Assert.Equal(1, events.Count(e => e.Level == Levels.Warning)); } }
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(); }
public void NotSettingTimedScopeResult_ChangesToSystemError() { LoggedEvents.Clear(); UnitTestTimedScopeLogger unitTestTimedScopeLogger = new UnitTestTimedScopeLogger(); 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(unitTestTimedScopeLogger, replyEventConfiguratorMock.Object, machineInformation, timedScopeStackManager)) { } TimedScopeLogEvent evt = unitTestTimedScopeLogger.SingleTimedScopeEvent(TestHooks.DefaultTimedScopeName); if (VerifyNotNullAndReturn(evt, "A scope event has been logged")) { Assert.Equal(evt.Result, TimedScopeResult.SystemError); } }