Skip to content

Commit

Permalink
SAVEPOINT
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisdoomen committed Sep 22, 2023
1 parent e5bcccf commit bd8ecd3
Show file tree
Hide file tree
Showing 29 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(IEnumerable<TExpe
CompileTimeType = typeof(IEnumerable<TExpectation>),
};

new EquivalencyValidator().AssertEquality(comparands, context);
new EquivalencyValidator().AssertEquivalency(comparands, context);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down Expand Up @@ -891,7 +891,7 @@ public AndWhichConstraint<TAssertions, T> ContainEquivalentOf<TExpectation>(TExp
CompileTimeType = typeof(TExpectation),
};

new EquivalencyValidator().AssertEquality(comparands, context);
new EquivalencyValidator().AssertEquivalency(comparands, context);

string[] failures = scope.Discard();

Expand Down Expand Up @@ -2369,7 +2369,7 @@ public AndConstraint<TAssertions> NotContainEquivalentOf<TExpectation>(TExpectat
CompileTimeType = typeof(TExpectation),
};

new EquivalencyValidator().AssertEquality(comparands, context);
new EquivalencyValidator().AssertEquivalency(comparands, context);

string[] failures = scope.Discard();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expe
CompileTimeType = typeof(TExpectation),
};

new EquivalencyValidator().AssertEquality(comparands, context);
new EquivalencyValidator().AssertEquivalency(comparands, context);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public AndConstraint<TAssertions> BeEquivalentTo(IEnumerable<string> expectation
CompileTimeType = typeof(IEnumerable<string>),
};

new EquivalencyValidator().AssertEquality(comparands, context);
new EquivalencyValidator().AssertEquivalency(comparands, context);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Equivalency/EquivalencyResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ namespace FluentAssertions.Equivalency;
public enum EquivalencyResult
{
ContinueWithNext,
AssertionCompleted
EquivalencyIsProven
}
12 changes: 6 additions & 6 deletions Src/FluentAssertions/Equivalency/EquivalencyValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ namespace FluentAssertions.Equivalency;
/// <summary>
/// Is responsible for validating the equivalency of a subject with another object.
/// </summary>
public class EquivalencyValidator : IEquivalencyValidator
internal class EquivalencyValidator : IEquivalencyValidator
{
private const int MaxDepth = 10;

public void AssertEquality(Comparands comparands, EquivalencyValidationContext context)
public void AssertEquivalency(Comparands comparands, EquivalencyValidationContext context)
{
using var scope = new AssertionScope();

scope.AssumeSingleCaller();
scope.AddReportable("configuration", () => context.Options.ToString());
scope.BecauseOf(context.Reason);

RecursivelyAssertEquality(comparands, context);
RecursivelyAssertEquivalency(comparands, context);

if (context.TraceWriter is not null)
{
scope.AppendTracing(context.TraceWriter.ToString());
}
}

public void RecursivelyAssertEquality(Comparands comparands, IEquivalencyValidationContext context)
public void RecursivelyAssertEquivalency(Comparands comparands, IEquivalencyValidationContext context)
{
var scope = AssertionScope.Current;

Expand Down Expand Up @@ -70,8 +70,8 @@ private void TryToProveNodesAreEquivalent(Comparands comparands, IEquivalencyVal

foreach (IEquivalencyStep step in AssertionOptions.EquivalencyPlan)
{
var result = step.Handle(comparands, context, this);
if (result == EquivalencyResult.AssertionCompleted)
EquivalencyResult result = step.Handle(comparands, context, this);
if (result == EquivalencyResult.EquivalencyIsProven)
{
context.Tracer.WriteLine(getMessage(step));
return;
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Equivalency/IEquivalencyStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface IEquivalencyStep
/// Executes an operation such as an equivalency assertion on the provided <paramref name="comparands"/>.
/// </summary>
/// <value>
/// Should return <see cref="EquivalencyResult.AssertionCompleted"/> if the subject matches the expectation or if no additional assertions
/// Should return <see cref="EquivalencyResult.EquivalencyIsProven"/> if the subject matches the expectation or if no additional assertions
/// have to be executed. Should return <see cref="EquivalencyResult.ContinueWithNext"/> otherwise.
/// </value>
/// <remarks>
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Equivalency/IEquivalencyValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ public interface IEquivalencyValidator
/// <summary>
/// Runs a deep recursive equivalency assertion on the provided <paramref name="comparands"/>.
/// </summary>
void RecursivelyAssertEquality(Comparands comparands, IEquivalencyValidationContext context);
void RecursivelyAssertEquivalency(Comparands comparands, IEquivalencyValidationContext context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
{
if (expectationAsArray.Length == 0)
{
return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

Digit digit = BuildDigitsRepresentingAllIndices(expectationAsArray);
Expand All @@ -36,12 +36,12 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon

IEquivalencyValidationContext itemContext = context.AsCollectionItem<object>(listOfIndices);

nestedValidator.RecursivelyAssertEquality(new Comparands(subject, expectation, typeof(object)), itemContext);
nestedValidator.RecursivelyAssertEquivalency(new Comparands(subject, expectation, typeof(object)), itemContext);
}
while (digit.Increment());
}

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

private static Digit BuildDigitsRepresentingAllIndices(Array subjectAsArray)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
}
}

return success ? EquivalencyResult.AssertionCompleted : EquivalencyResult.ContinueWithNext;
return success ? EquivalencyResult.EquivalencyIsProven : EquivalencyResult.ContinueWithNext;
}

private bool AppliesTo(Comparands comparands, INode currentNode) => predicate(new ObjectInfo(comparands, currentNode));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
context.Tracer.WriteLine(member =>
Invariant($"Recursing into dictionary item {key} at {member.Description}"));

nestedValidator.RecursivelyAssertEquality(new Comparands(subject[key], expectation[key], typeof(object)),
nestedValidator.RecursivelyAssertEquivalency(new Comparands(subject[key], expectation[key], typeof(object)),
context.AsDictionaryItem<object, IDictionary>(key));
}
else
Expand All @@ -37,7 +37,7 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
}
}

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

private static bool PreconditionsAreMet(IDictionary expectation, IDictionary subject)
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Equivalency/Steps/EnumEqualityStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
}
}

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

private static void HandleByValue(Comparands comparands, Reason reason)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
validator.Execute(ToArray(comparands.Subject), ToArray(comparands.Expectation));
}

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

private static bool AssertSubjectIsCollection(object subject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private string[] TryToMatch<T>(object subject, T expectation, int expectationInd
{
using var scope = new AssertionScope();

parent.RecursivelyAssertEquality(new Comparands(subject, expectation, typeof(T)),
parent.RecursivelyAssertEquivalency(new Comparands(subject, expectation, typeof(T)),
context.AsCollectionItem<T>(expectationIndex));

return scope.Discard();
Expand All @@ -208,7 +208,7 @@ private bool StrictlyMatchAgainst<T>(object[] subjects, T expectation, int expec
object subject = subjects[expectationIndex];
IEquivalencyValidationContext equivalencyValidationContext = context.AsCollectionItem<T>(expectationIndex);

parent.RecursivelyAssertEquality(new Comparands(subject, expectation, typeof(T)), equivalencyValidationContext);
parent.RecursivelyAssertEquivalency(new Comparands(subject, expectation, typeof(T)), equivalencyValidationContext);

bool failed = scope.HasFailures();
return !failed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
.FailWith("Expected {context:object} to be equal to {1} according to {0}{because}, but {2} was not.",
comparer.ToString(), comparands.Expectation, comparands.Subject);

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

public override string ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
AssertDictionaryEquivalence(comparands, context, nestedValidator, actualDictionary, expectedDictionary);
}

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}

Expand Down Expand Up @@ -158,7 +158,7 @@ private static void AssertDictionaryEquivalence<TSubjectKey, TSubjectValue, TExp
{
var nestedComparands = new Comparands(subject[key], expectation[key], typeof(TExpectedValue));

parent.RecursivelyAssertEquality(nestedComparands,
parent.RecursivelyAssertEquivalency(nestedComparands,
context.AsDictionaryItem<TExpectedKey, TExpectedValue>(key));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
}
}

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

private static void HandleImpl<T>(EnumerableEquivalencyValidator validator, object[] subject, IEnumerable<T> expectation) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
IEquivalencyValidator nestedValidator)
{
return ReferenceEquals(comparands.Subject, comparands.Expectation)
? EquivalencyResult.AssertionCompleted
? EquivalencyResult.EquivalencyIsProven
: EquivalencyResult.ContinueWithNext;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
{
foreach (IEquivalencyStep step in context.Options.UserEquivalencySteps)
{
if (step.Handle(comparands, context, nestedValidator) == EquivalencyResult.AssertionCompleted)
if (step.Handle(comparands, context, nestedValidator) == EquivalencyResult.EquivalencyIsProven)
{
return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
{
comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

return EquivalencyResult.ContinueWithNext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon

if (!ValidateAgainstNulls(comparands, context.CurrentNode))
{
return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

bool subjectIsString = ValidateSubjectIsString(comparands, context.CurrentNode);
Expand All @@ -31,7 +31,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
.Be(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);
}

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

private static bool ValidateAgainstNulls(Comparands comparands, INode currentNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
}
}

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

private static void AssertMemberEquality(Comparands comparands, IEquivalencyValidationContext context,
Expand All @@ -73,7 +73,7 @@ private static void AssertMemberEquality(Comparands comparands, IEquivalencyVali
selectedMember.Name = matchingMember.Name;
}

parent.RecursivelyAssertEquality(nestedComparands, context.AsNestedMember(selectedMember));
parent.RecursivelyAssertEquivalency(nestedComparands, context.AsNestedMember(selectedMember));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon

comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

return EquivalencyResult.ContinueWithNext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc

subject.Should().Be(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc

subject.Should().BeEquivalentTo(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc

subject.Should().BeEquivalentTo(expectation, context.Reason.FormattedMessage, context.Reason.Arguments);

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Numeric/ComparableTypeAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expe
CompileTimeType = typeof(TExpectation),
};

new EquivalencyValidator().AssertEquality(comparands, context);
new EquivalencyValidator().AssertEquivalency(comparands, context);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/ObjectAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expe
CompileTimeType = typeof(TExpectation),
};

new EquivalencyValidator().AssertEquality(comparands, context);
new EquivalencyValidator().AssertEquivalency(comparands, context);

return new AndConstraint<TAssertions>((TAssertions)this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
{
((DateTime)comparands.Subject).Should().BeCloseTo(time, 1.Minutes());

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}

return EquivalencyResult.ContinueWithNext;
Expand Down Expand Up @@ -822,7 +822,7 @@ private class AlwaysHandleEquivalencyStep : IEquivalencyStep
public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context,
IEquivalencyValidator nestedValidator)
{
return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}

Expand All @@ -841,7 +841,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
IEquivalencyValidator nestedValidator)
{
comparands.Subject.Should().Be(comparands.Expectation, context.Reason.FormattedMessage, context.Reason.Arguments);
return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}

Expand All @@ -858,7 +858,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
IEquivalencyValidator nestedValidator)
{
doAction();
return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/FluentAssertions.Specs/AssertionOptionsSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationCon
{
Execute.Assertion.FailWith(GetType().FullName);

return EquivalencyResult.AssertionCompleted;
return EquivalencyResult.EquivalencyIsProven;
}
}
}

0 comments on commit bd8ecd3

Please sign in to comment.