Telemetry type used to track exceptions.
Inheritance: ITelemetry, ISupportProperties
        public void ConstructorAddsExceptionToExceptionPropertyAndExceptionsCollectionProperty()
        {
            ServiceLocator.AddService<IPlatformService>(new PlatformService());
            Exception constructorException = new Exception("ConstructorException");
            var testExceptionTelemetry = new ExceptionTelemetry(constructorException);

            Assert.Same(constructorException, testExceptionTelemetry.Exception);
            Assert.Equal(constructorException.Message, testExceptionTelemetry.Exceptions.First().message);
        }
        public void ExceptionPropertySetterReplacesExceptionDetailsInExceptionsCollectionProperty()
        {
            ServiceLocator.AddService<IPlatformService>(new PlatformService());
            Exception constructorException = new Exception("ConstructorException");
            var testExceptionTelemetry = new ExceptionTelemetry(constructorException);

            Exception nextException = new Exception("NextException");
            testExceptionTelemetry.Exception = nextException;

            Assert.Same(nextException, testExceptionTelemetry.Exception);
            Assert.Equal(nextException.Message, testExceptionTelemetry.Exceptions.First().message);
        }
        public void SerializeWritesNullValuesAsExpectedByEndpoint()
        {
            ExceptionTelemetry original = new ExceptionTelemetry();
            original.Exception = null;
            original.SeverityLevel = null;
            var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);

            Assert.Equal(2, item.Data.BaseData.Ver);
        }
 public void MetricsReturnsEmptyDictionaryByDefaultToPreventNullReferenceExceptions()
 {
     var @exception = new ExceptionTelemetry(new Exception());
     var measurements = @exception.Metrics;
     Assert.NotNull(measurements);
 }
 public void ConstructorDoesNotSetSeverityLevel()
 {
     var telemetry = new ExceptionTelemetry();
     Assert.Equal(null, telemetry.SeverityLevel);
 }
 public void HandledAtReturnsUnhandledByDefault()
 {
     var telemetry = new ExceptionTelemetry();
     Assert.Equal(ExceptionHandledAt.Unhandled, telemetry.HandledAt);
 }
        public void SanitizeWillTrimMetricsNameAndValueInExceptionTelemetry()
        {
            ExceptionTelemetry telemetry = new ExceptionTelemetry();
            telemetry.Metrics.Add(new string('Y', Property.MaxDictionaryNameLength) + 'X', 42.0);
            telemetry.Metrics.Add(new string('Y', Property.MaxDictionaryNameLength) + 'Y', 42.0);

            ((ITelemetry)telemetry).Sanitize();

            Assert.Equal(2, telemetry.Metrics.Count);
            Assert.Equal(new string('Y', Property.MaxDictionaryNameLength), telemetry.Metrics.Keys.ToArray()[0]);
            Assert.Equal(new string('Y', Property.MaxDictionaryNameLength - 3) + "001", telemetry.Metrics.Keys.ToArray()[1]);
        }
        private static ExceptionTelemetry CreateExceptionTelemetry(Exception exception = null)
        {
            if (exception == null)
            {
                exception = new Exception();
            }

            ExceptionTelemetry output = new ExceptionTelemetry(exception) { Timestamp = DateTimeOffset.UtcNow };
            output.Context.InstrumentationKey = "required";
            return output;
        }
        public void SerializePopulatesRequiredFieldsOfExceptionTelemetry()
        {
            var exceptionTelemetry = new ExceptionTelemetry();
            exceptionTelemetry.Context.InstrumentationKey = Guid.NewGuid().ToString();
            var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(exceptionTelemetry);

            Assert.Equal(2, item.Data.BaseData.Ver);
            Assert.NotNull(item.Data.BaseData.HandledAt);
            Assert.NotNull(item.Data.BaseData.Exceptions);
            Assert.Equal(0, item.Data.BaseData.Exceptions.Count); // constructor without parameters does not initialize exception object
        }
 public void ExceptionTelemetryReturnsNonNullContext()
 {
     ExceptionTelemetry item = new ExceptionTelemetry();
     Assert.NotNull(item.Context);
 }
Exemplo n.º 11
0
        public void ConstructorDoesNotSetSeverityLevel()
        {
            var telemetry = new ExceptionTelemetry();

            Assert.Equal(null, telemetry.SeverityLevel);
        }
Exemplo n.º 12
0
        public void HandledAtReturnsUnhandledByDefault()
        {
            var telemetry = new ExceptionTelemetry();

            Assert.Equal(ExceptionHandledAt.Unhandled, telemetry.HandledAt);
        }
Exemplo n.º 13
0
        public void ExceptionTelemetryReturnsNonNullContext()
        {
            ExceptionTelemetry item = new ExceptionTelemetry();

            Assert.NotNull(item.Context);
        }