Skip to content

Commit

Permalink
Inline Handle
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup committed Apr 30, 2023
1 parent d3f5a18 commit b6f0d8c
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public class GenericDictionaryEquivalencyStep : IEquivalencyStep
Type expectationType = comparands.GetExpectedType(context.Options);
if (DictionaryInterfaceInfo.FindFrom(expectationType, "expectation") is { } expectedDictionary)
{
Handle(comparands, expectedDictionary, context, nestedValidator);
if (AssertSubjectIsNotNull(comparands.Subject)
&& EnsureSubjectIsDictionary(comparands, expectedDictionary) is { } actualDictionary)
{
AssertDictionaryEquivalence(comparands, context, nestedValidator, actualDictionary, expectedDictionary);
}

return EquivalencyResult.AssertionCompleted;
}
Expand All @@ -33,17 +37,6 @@ public class GenericDictionaryEquivalencyStep : IEquivalencyStep
return EquivalencyResult.ContinueWithNext;
}

private static void Handle(Comparands comparands, DictionaryInterfaceInfo expectedDictionary,
IEquivalencyValidationContext context,
IEquivalencyValidator nestedValidator)
{
if (AssertSubjectIsNotNull(comparands.Subject)
&& EnsureSubjectIsDictionary(comparands, expectedDictionary) is { } actualDictionary)
{
AssertDictionaryEquivalence(comparands, context, nestedValidator, actualDictionary, expectedDictionary);
}
}

private static bool AssertSubjectIsNotNull(object subject)
{
return AssertionScope.Current
Expand Down

0 comments on commit b6f0d8c

Please sign in to comment.