public void TraceSingle(GetTraceMessage getTraceMessage) { if (Tracer != null) { string path = SelectedMemberDescription.Length > 0 ? SelectedMemberDescription : "root"; Tracer.AddSingle($"{getTraceMessage(path)}"); } }
/// <summary> /// Starts a block that scopes an operation that will be written to the currently configured <see cref="ITraceWriter"/> /// after the returned disposable is disposed. /// </summary> /// <remarks> /// If no tracer has been configured for the <see cref="IEquivalencyValidationContext"/>, the call will be ignored. /// </remarks> public IDisposable WriteBlock(GetTraceMessage getTraceMessage) { if (traceWriter is not null) { return(traceWriter.AddBlock(getTraceMessage(currentNode))); } else { return(new Disposable(() => { })); } }
public IDisposable TraceBlock(GetTraceMessage getTraceMessage) { if (Tracer != null) { string path = SelectedMemberDescription.Length > 0 ? SelectedMemberDescription : "root"; return(Tracer.AddBlock(getTraceMessage(path))); } else { return(new Disposable(() => {})); } }
private bool LooselyMatchAgainst <T>(IList <object> subjects, T expectation, int expectationIndex) { var results = new AssertionResultSet(); int index = 0; GetTraceMessage getMessage = path => $"Comparing subject at {path}[{index}] with the expectation at {path}[{expectationIndex}]"; int indexToBeRemoved = -1; for (var metaIndex = 0; metaIndex < unmatchedSubjectIndexes.Count; metaIndex++) { index = unmatchedSubjectIndexes[metaIndex]; object subject = subjects[index]; using (context.TraceBlock(getMessage)) { string[] failures = TryToMatch(subject, expectation, expectationIndex); results.AddSet(index, failures); if (results.ContainsSuccessfulSet()) { context.TraceSingle(_ => "It's a match"); indexToBeRemoved = metaIndex; break; } else { context.TraceSingle(_ => $"Contained {failures.Length} failures"); } } } if (indexToBeRemoved != -1) { unmatchedSubjectIndexes.RemoveAt(indexToBeRemoved); } foreach (string failure in results.SelectClosestMatchFor(expectationIndex)) { AssertionScope.Current.AddPreFormattedFailure(failure); } return(indexToBeRemoved != -1); }
/// <summary> /// Writes a single line to the currently configured <see cref="ITraceWriter"/>. /// </summary> /// <remarks> /// If no tracer has been configured, the call will be ignored. /// </remarks> public void WriteLine(GetTraceMessage getTraceMessage) { traceWriter?.AddSingle(getTraceMessage(currentNode)); }