Skip to content

Commit

Permalink
Simplify deferred allocation with local function
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup committed Mar 24, 2024
1 parent ba6028b commit 694ca94
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Src/FluentAssertions/Equivalency/EquivalencyValidator.cs
Expand Up @@ -66,14 +66,16 @@ private void TryToProveNodesAreEquivalent(Comparands comparands, IEquivalencyVal
{
using var _ = context.Tracer.WriteBlock(node => node.Description);

Func<IEquivalencyStep, GetTraceMessage> getMessage = step => _ => $"Equivalency was proven by {step.GetType().Name}";

foreach (IEquivalencyStep step in AssertionOptions.EquivalencyPlan)
{
var result = step.Handle(comparands, context, this);
if (result == EquivalencyResult.AssertionCompleted)
{
context.Tracer.WriteLine(getMessage(step));
context.Tracer.WriteLine(GetMessage(step));

static GetTraceMessage GetMessage(IEquivalencyStep step) =>
_ => $"Equivalency was proven by {step.GetType().Name}";

return;
}
}
Expand Down

0 comments on commit 694ca94

Please sign in to comment.