Ejemplo n.º 1
0
        public void GivenHandledExceptionTypes_WhenHandleExpection_ThenMetricLoggedAndTrueReturned_Test(System.Type exType)
        {
            var log = Substitute.For <ITelemetryLogger>();
            var ex  = Activator.CreateInstance(exType) as Exception;

            var exProcessor = new NormalizationExceptionTelemetryProcessor();
            var handled     = exProcessor.HandleException(ex, log);

            Assert.True(handled);

            log.ReceivedWithAnyArgs(1).LogMetric(null, default(double));
        }
Ejemplo n.º 2
0
        public void GivenUnhandledExceptionTypes_WhenHandleExpection_ThenMetricLoggedAndFalseReturned_Test(System.Type exType)
        {
            var log = Substitute.For <ITelemetryLogger>();
            var ex  = Activator.CreateInstance(exType) as Exception;

            var exProcessor = new NormalizationExceptionTelemetryProcessor();
            var handled     = exProcessor.HandleException(ex, log);

            Assert.False(handled);

            log.Received(1).LogError(ex);
            log.Received(1).LogMetric(
                Arg.Is <Metric>(m =>
                                string.Equals(m.Name, nameof(IomtMetrics.UnhandledException)) &&
                                string.Equals(m.Dimensions[DimensionNames.Name], exType.Name)),
                1);
        }