public void TestExceptionTypeAttribute_ShouldSetExceptionTypeHang_ExceptionTypeAttributeIsCorrect() { var report = new BacktraceReport(new BacktraceUnhandledException("ANRException: Blocked thread detected", string.Empty)); var testAttributes = new BacktraceAttributes(report, null); Assert.AreEqual("Hang", testAttributes.Attributes["error.type"]); }
public IEnumerator TestCorrectDictionaryGeneration_CreateCorrectAttributesDictionary_WithDiffrentClientAttributes() { var exception = new FileNotFoundException(); var reportAttributeKey = "report_attr"; var reportAttributeValue = string.Format("{0}-value", reportAttributeKey); var reportAttributes = new Dictionary <string, object>() { { reportAttributeKey, reportAttributeValue } }; var exceptionReport = new BacktraceReport(exception, reportAttributes); string clientAttributeKey = "client_attr"; string clientAttributeValue = string.Format("{0}-value", clientAttributeKey); var clientAttributes = new Dictionary <string, object>() { { clientAttributeKey, clientAttributeValue } }; var testObject = new BacktraceAttributes(exceptionReport, clientAttributes); Assert.IsTrue(testObject.Attributes.Keys.Any(n => n == clientAttributeKey)); Assert.IsTrue(testObject.Attributes.Keys.Any(n => n == reportAttributeKey)); Assert.IsTrue(testObject.Attributes[clientAttributeKey] as string == clientAttributeValue); Assert.IsTrue(testObject.Attributes[reportAttributeKey] as string == reportAttributeValue); yield return(null); }
private void SetAttributes(Dictionary <string, object> clientAttributes) { var backtraceAttributes = new BacktraceAttributes(Report, clientAttributes); Attributes = backtraceAttributes.Attributes; Annotations = new Annotations(Report.CallingAssembly, backtraceAttributes.ComplexAttributes); }
public void TestExceptionTypeAttribute_ShouldSetExceptionTypeUnhandledException_ExceptionTypeAttributeIsCorrect() { var report = new BacktraceReport(new BacktraceUnhandledException("foo", string.Empty)); var testAttributes = new BacktraceAttributes(report, null); Assert.AreEqual("Unhandled exception", testAttributes.Attributes["error.type"]); }
public void TestExceptionTypeAttribute_ShouldSetExceptionTypeException_ExceptionTypeAttributeIsCorrect() { var report = new BacktraceReport(new Exception("foo")); var testAttributes = new BacktraceAttributes(report, null); Assert.AreEqual("Exception", testAttributes.Attributes["error.type"]); }
/// <summary> /// Create instance of report data /// </summary> /// <param name="report">Current report</param> /// <param name="scopedAttributes">BacktraceClient's attributes</param> public BacktraceData(BacktraceReportBase <T> report, Dictionary <string, T> scopedAttributes) { _report = report; _backtraceAttributes = new BacktraceAttributes <T>(_report, scopedAttributes); //reading exception stack _exceptionStack = _report.GetExceptionStack(); ThreadData = new ThreadData(report.CallingAssembly, _exceptionStack); }
public IEnumerator TestAttributes_ValidReport_AttributesExists() { var report = new BacktraceReport(new Exception("test")); var data = new BacktraceData(report, null); var json = data.Attributes.ToJson(); var deserializedData = BacktraceAttributes.Deserialize(json); Assert.IsTrue(deserializedData.Attributes.Count == data.Attributes.Attributes.Count); yield return(null); }
public void TestFingerprintAttribute() { string fingerprint = "fingerprint for testing purpose"; var report = new BacktraceReport("testMessage") { Fingerprint = fingerprint }; var attributes = new BacktraceAttributes(report, null); Assert.IsTrue(attributes.Attributes.ContainsKey("_mod_fingerprint")); Assert.IsFalse(attributes.Attributes.ContainsKey("_mod_factor")); Assert.AreEqual(attributes.Attributes["_mod_fingerprint"], fingerprint); }
public IEnumerator TestAttributesGeneration_CreateCorrectAttributes_WithDiffrentReportConfiguration() { var report = new BacktraceReport("message"); Assert.DoesNotThrow(() => new BacktraceAttributes(report, null)); var exception = new FileNotFoundException(); var exceptionReport = new BacktraceReport(exception, new Dictionary <string, object>() { { "attr", "attr" } }); var attributes = new BacktraceAttributes(exceptionReport, null); Assert.IsTrue(attributes.Attributes.Count > 0); yield return(null); }
public void TestFactorAttribute() { string factor = "factor attribute value"; var report = new BacktraceReport("testMessage") { Factor = factor }; var attributes = new BacktraceAttributes(report, null); Assert.IsTrue(attributes.Attributes.ContainsKey("_mod_factor")); Assert.AreEqual(attributes.Attributes["_mod_factor"], factor); Assert.IsFalse(attributes.Attributes.ContainsKey("_mod_fingerprint")); }
/// <summary> /// Convert JSON to Backtrace Data /// </summary> /// <param name="json">Backtrace Data JSON</param> /// <returns>Backtrace Data instance</returns> public static BacktraceData Deserialize(string json) { var @object = BacktraceJObject.Parse(json); var classfiers = @object == null ? null : @object["classifiers"] .Select(n => n.Value <string>()).ToArray() ?? null; return(new BacktraceData() { Uuid = new Guid(@object.Value <string>("uuid")), Timestamp = @object.Value <long>("timestamp"), MainThread = @object.Value <string>("mainThread"), Classifier = classfiers, Annotation = Annotations.Deserialize(@object["annotations"]), Attributes = BacktraceAttributes.Deserialize(@object["attributes"]), ThreadData = ThreadData.DeserializeThreadInformation(@object["threads"]) }); }
public void TestAttributesCreation() { var report = new BacktraceReportBase <string>("testMessage"); //test object creation Assert.DoesNotThrow(() => new BacktraceAttributes <string>(report, null)); //test empty exception Assert.DoesNotThrow(() => { var backtraceAttributes = new BacktraceAttributes <string>(report, new Dictionary <string, string>()); backtraceAttributes.SetExceptionAttributes(new BacktraceReportBase <string>("message")); }); //test null Assert.DoesNotThrow(() => { var backtraceAttributes = new BacktraceAttributes <string>(report, new Dictionary <string, string>()); backtraceAttributes.SetExceptionAttributes(null); }); }
/// <summary> /// Set report attributes and annotations /// </summary> /// <param name="clientAttributes">Backtrace client attributes</param> private void SetAttributes(Dictionary <string, object> clientAttributes) { Attributes = new BacktraceAttributes(Report, clientAttributes); Annotation = new Annotations(Attributes.ComplexAttributes); }