/// <summary> /// The to formatted string. /// </summary> /// <param name="tabs"> /// the tabs The tabs. /// </param> /// <returns> /// The System.String. /// </returns> public string ToFormattedString(int tabs = 0) { var tsb = new TraceStringBuilder(tabs); tsb.AppendTitle(this); using (tsb.IndentBlock()) { tsb.AppendProperty("InvokeCount", this.InvokeCount); } return tsb.ToString(); }
/// <summary> /// The to formatted string. /// </summary> /// <param name="tabs"> /// the tabs The tabs. /// </param> /// <returns> /// The System.String. /// </returns> public string ToFormattedString(int tabs = 0) { var tsb = new TraceStringBuilder(tabs); tsb.AppendLine(this.GetType().Name); using (tsb.IndentBlock()) { tsb.AppendProperty("Message", this.Message); tsb.AppendProperty("BookmarkName", this.BookmarkName); tsb.AppendProperty("Result", this.Result); tsb.AppendProperty("Value", this.Value); } return tsb.ToString(); }
public void AppendPropertyAppendsTraceable() { // Arrange const string Expected = @" Test Prop: TestTracable Children { ChildTraceable { } ChildTraceable { Strings { 0 } } ChildTraceable { Strings { 0 1 } } ChildTraceable { Strings { 0 1 2 } } } "; var tsb = new TraceStringBuilder(1); var prop = new TestTracable(); // Act tsb.AppendLine("Test"); tsb.AppendProperty("Prop", prop); var actual = tsb.ToString(); Trace.WriteLine(actual); // Assert Assert.AreEqual(Expected, actual, this.StringsDifferAt(Expected, actual)); }
public void AppendPropertyIndentsNewLines() { // Arrange const string Expected = @" Test MultiLine: Line 1 Line 2 Line 3 "; const string MultiLine = @"Line 1 Line 2 Line 3"; var tsb = new TraceStringBuilder(1); // Act tsb.AppendLine("Test"); tsb.AppendProperty("MultiLine", MultiLine); var actual = tsb.ToString(); Trace.WriteLine(actual); // Assert Assert.AreEqual(Expected, actual, this.StringsDifferAt(Expected, actual)); }
/// <summary> /// Traces additional data about a tracking record /// </summary> /// <param name="tsb"> /// The stringBuilder. /// </param> /// <param name="option"> /// A TrackingOptions value which specifies data to include in the trace /// </param> /// <param name="instanceId"> /// The instance ID of the tracking record /// </param> /// <param name="annotations"> /// The annotations dictionary /// </param> /// <param name="arguments"> /// The arguments dictionary /// </param> /// <param name="variables"> /// The variables dictionary /// </param> /// <param name="data"> /// The data dictionary /// </param> /// <param name="eventTime"> /// The event time /// </param> internal static void AppendInstance( TraceStringBuilder tsb, TrackingOption option, Guid instanceId, IDictionary<string, string> annotations, IDictionary<string, object> arguments, IDictionary<string, object> variables, IDictionary<string, object> data, DateTime eventTime) { if (!AnythingToTrace(option, tsb.Options, annotations, arguments, variables, data)) { return; } tsb.AppendLine(); using (tsb.IndentBlock()) { if (option.HasFlag(TrackingOption.InstanceId)) { tsb.AppendProperty("InstanceId", instanceId); } if (option.HasFlag(TrackingOption.Time)) { tsb.AppendProperty("Event Time", eventTime.ToString(EventTimeFormat)); } if (option.HasFlag(TrackingOption.Annotations)) { tsb.AppendDictionary("Annotations", annotations); } if (option.HasFlag(TrackingOption.Arguments)) { tsb.AppendDictionary("Arguments", arguments); } if (option.HasFlag(TrackingOption.Variables)) { tsb.AppendDictionary("Variables", variables); } if (option.HasFlag(TrackingOption.Data)) { tsb.AppendDictionary("Data", data); } } }