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); }
public void TestProcess_IgnoresTemplateTaskArray() { // arrange bool actual = true; bool expected = false; ExceptionTelemetryEnhancer sut = new ExceptionTelemetryEnhancer(new MockTransmissionProcessor((x) => { ExceptionTelemetry t = x as ExceptionTelemetry; if (t != null) { actual = t.Properties.ContainsKey("TemplateTaskArrayPropertyException.TaskArray"); } })); TemplateTaskArrayPropertyException ex = new TemplateTaskArrayPropertyException("Exception Message", new Task <int>[] { new Task <int>(() => { return(5); }), new Task <int>(() => { return(5); }), new Task <int>(() => { return(5); }), new Task <int>(() => { return(5); }) }); ExceptionTelemetry telemetry = new ExceptionTelemetry(ex); // act sut.Process(telemetry); // assert Assert.AreEqual(expected, actual); }
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); }
public void TestProcess_IgnoresBaseTaskArray() { // arrange bool actual = true; bool expected = false; ExceptionTelemetryEnhancer sut = new ExceptionTelemetryEnhancer(new MockTransmissionProcessor((x) => { ExceptionTelemetry t = x as ExceptionTelemetry; if (t != null) { actual = t.Properties.ContainsKey("BaseTaskArrayPropertyException.TaskArray"); } })); BaseTaskArrayPropertyException ex = new BaseTaskArrayPropertyException("Exception Message", new Task[] { Task.Delay(1000), Task.Delay(1000), Task.Delay(1000), Task.Delay(1000) }); ExceptionTelemetry telemetry = new ExceptionTelemetry(ex); // act sut.Process(telemetry); // assert Assert.AreEqual(expected, actual); }
public void TestProcess_Array() { // arrange string actual = string.Empty; string expected = "[1,2,3,4,5]"; ExceptionTelemetryEnhancer sut = new ExceptionTelemetryEnhancer(new MockTransmissionProcessor((x) => { ExceptionTelemetry t = x as ExceptionTelemetry; if (t != null) { if (t.Properties.ContainsKey("ArrayPropertyException.CustomArray")) { actual = t.Properties["ArrayPropertyException.CustomArray"]; } } })); ArrayPropertyException ex = new ArrayPropertyException("Exception Message", new int[] { 1, 2, 3, 4, 5 }); ExceptionTelemetry telemetry = new ExceptionTelemetry(ex); // act sut.Process(telemetry); // assert Assert.AreEqual(expected, actual); }