Beispiel #1
0
        public void TestProcess_IgnoresDuplicateData()
        {
            // arrange
            bool actualStackTrace          = true;
            bool actualMessage             = true;
            bool actualTargetSite          = true;
            bool expected                  = false;
            ExceptionTelemetryEnhancer sut = new ExceptionTelemetryEnhancer(new MockTransmissionProcessor((x) =>
            {
                ExceptionTelemetry t = x as ExceptionTelemetry;
                if (t != null)
                {
                    actualStackTrace = t.Properties.ContainsKey("CustomPropertyException.StackTrace");
                    actualMessage    = t.Properties.ContainsKey("CustomPropertyException.Message");
                    actualTargetSite = t.Properties.ContainsKey("CustomPropertyException.TargetSite");
                }
            }));
            CustomPropertyException ex        = new CustomPropertyException("Exception Message", "Important Property");
            ExceptionTelemetry      telemetry = new ExceptionTelemetry(ex);

            // act
            sut.Process(telemetry);

            // assert
            Assert.AreEqual(expected, actualStackTrace);
            Assert.AreEqual(expected, actualMessage);
            Assert.AreEqual(expected, actualTargetSite);
        }
Beispiel #2
0
        public void TestProcess_CustomProperty()
        {
            // arrange
            string actual   = string.Empty;
            string expected = "\"Important Property\"";
            ExceptionTelemetryEnhancer sut = new ExceptionTelemetryEnhancer(new MockTransmissionProcessor((x) =>
            {
                ExceptionTelemetry t = x as ExceptionTelemetry;
                if (t != null)
                {
                    if (t.Properties.ContainsKey("CustomPropertyException.CustomProperty"))
                    {
                        actual = t.Properties["CustomPropertyException.CustomProperty"];
                    }
                }
            }));
            CustomPropertyException ex        = new CustomPropertyException("Exception Message", "Important Property");
            ExceptionTelemetry      telemetry = new ExceptionTelemetry(ex);

            // act
            sut.Process(telemetry);

            // assert
            Assert.AreEqual(expected, actual);
        }