Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global record equivalency settings were not taken into account #1984

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -65,7 +65,7 @@ public IEnumerable<IEquivalencyStep> UserEquivalencySteps

public bool ExcludeNonBrowsableOnExpectation => inner.ExcludeNonBrowsableOnExpectation;

public bool CompareRecordsByValue => inner.CompareRecordsByValue;
public bool? CompareRecordsByValue => inner.CompareRecordsByValue;

public EqualityStrategy GetEqualityStrategy(Type type)
{
Expand Down
Expand Up @@ -88,7 +88,7 @@ public interface IEquivalencyAssertionOptions
/// <summary>
/// Gets a value indicating whether records should be compared by value instead of their members
/// </summary>
bool CompareRecordsByValue { get; }
bool? CompareRecordsByValue { get; }

/// <summary>
/// Gets the currently configured tracer, or <c>null</c> if no tracing was configured.
Expand Down
Expand Up @@ -60,7 +60,7 @@ public abstract class SelfReferenceEquivalencyAssertionOptions<TSelf> : IEquival
private bool ignoreNonBrowsableOnSubject;
private bool excludeNonBrowsableOnExpectation;

private bool compareRecordsByValue;
private bool? compareRecordsByValue;

#endregion

Expand Down Expand Up @@ -176,7 +176,7 @@ IEnumerable<IMemberSelectionRule> IEquivalencyAssertionOptions.SelectionRules

bool IEquivalencyAssertionOptions.ExcludeNonBrowsableOnExpectation => excludeNonBrowsableOnExpectation;

public bool CompareRecordsByValue => compareRecordsByValue;
public bool? CompareRecordsByValue => compareRecordsByValue;

EqualityStrategy IEquivalencyAssertionOptions.GetEqualityStrategy(Type requestedType)
{
Expand All @@ -202,9 +202,9 @@ EqualityStrategy IEquivalencyAssertionOptions.GetEqualityStrategy(Type requested
{
strategy = EqualityStrategy.ForceEquals;
}
else if (type.IsRecord())
else if ((compareRecordsByValue.HasValue || getDefaultEqualityStrategy is null) && type.IsRecord())
{
strategy = compareRecordsByValue ? EqualityStrategy.ForceEquals : EqualityStrategy.ForceMembers;
strategy = compareRecordsByValue is true ? EqualityStrategy.ForceEquals : EqualityStrategy.ForceMembers;
}
else
{
Expand Down Expand Up @@ -760,7 +760,7 @@ public override string ToString()
builder.AppendLine($"- Compare tuples by their properties");
builder.AppendLine($"- Compare anonymous types by their properties");

if (compareRecordsByValue)
if (compareRecordsByValue is true)
{
builder.AppendLine("- Compare records by value");
}
Expand Down
Expand Up @@ -864,7 +864,7 @@ namespace FluentAssertions.Equivalency
public interface IEquivalencyAssertionOptions
{
bool AllowInfiniteRecursion { get; }
bool CompareRecordsByValue { get; }
bool? CompareRecordsByValue { get; }
FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
FluentAssertions.Equivalency.CyclicReferenceHandling CyclicReferenceHandling { get; }
FluentAssertions.Equivalency.EnumEquivalencyHandling EnumEquivalencyHandling { get; }
Expand Down Expand Up @@ -1027,7 +1027,7 @@ namespace FluentAssertions.Equivalency
where TSelf : FluentAssertions.Equivalency.SelfReferenceEquivalencyAssertionOptions<TSelf>
{
protected SelfReferenceEquivalencyAssertionOptions(FluentAssertions.Equivalency.IEquivalencyAssertionOptions defaults) { }
public bool CompareRecordsByValue { get; }
public bool? CompareRecordsByValue { get; }
public FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
protected FluentAssertions.Equivalency.OrderingRuleCollection OrderingRules { get; }
Expand Down
Expand Up @@ -877,7 +877,7 @@ namespace FluentAssertions.Equivalency
public interface IEquivalencyAssertionOptions
{
bool AllowInfiniteRecursion { get; }
bool CompareRecordsByValue { get; }
bool? CompareRecordsByValue { get; }
FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
FluentAssertions.Equivalency.CyclicReferenceHandling CyclicReferenceHandling { get; }
FluentAssertions.Equivalency.EnumEquivalencyHandling EnumEquivalencyHandling { get; }
Expand Down Expand Up @@ -1040,7 +1040,7 @@ namespace FluentAssertions.Equivalency
where TSelf : FluentAssertions.Equivalency.SelfReferenceEquivalencyAssertionOptions<TSelf>
{
protected SelfReferenceEquivalencyAssertionOptions(FluentAssertions.Equivalency.IEquivalencyAssertionOptions defaults) { }
public bool CompareRecordsByValue { get; }
public bool? CompareRecordsByValue { get; }
public FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
protected FluentAssertions.Equivalency.OrderingRuleCollection OrderingRules { get; }
Expand Down
Expand Up @@ -864,7 +864,7 @@ namespace FluentAssertions.Equivalency
public interface IEquivalencyAssertionOptions
{
bool AllowInfiniteRecursion { get; }
bool CompareRecordsByValue { get; }
bool? CompareRecordsByValue { get; }
FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
FluentAssertions.Equivalency.CyclicReferenceHandling CyclicReferenceHandling { get; }
FluentAssertions.Equivalency.EnumEquivalencyHandling EnumEquivalencyHandling { get; }
Expand Down Expand Up @@ -1027,7 +1027,7 @@ namespace FluentAssertions.Equivalency
where TSelf : FluentAssertions.Equivalency.SelfReferenceEquivalencyAssertionOptions<TSelf>
{
protected SelfReferenceEquivalencyAssertionOptions(FluentAssertions.Equivalency.IEquivalencyAssertionOptions defaults) { }
public bool CompareRecordsByValue { get; }
public bool? CompareRecordsByValue { get; }
public FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
protected FluentAssertions.Equivalency.OrderingRuleCollection OrderingRules { get; }
Expand Down
Expand Up @@ -864,7 +864,7 @@ namespace FluentAssertions.Equivalency
public interface IEquivalencyAssertionOptions
{
bool AllowInfiniteRecursion { get; }
bool CompareRecordsByValue { get; }
bool? CompareRecordsByValue { get; }
FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
FluentAssertions.Equivalency.CyclicReferenceHandling CyclicReferenceHandling { get; }
FluentAssertions.Equivalency.EnumEquivalencyHandling EnumEquivalencyHandling { get; }
Expand Down Expand Up @@ -1027,7 +1027,7 @@ namespace FluentAssertions.Equivalency
where TSelf : FluentAssertions.Equivalency.SelfReferenceEquivalencyAssertionOptions<TSelf>
{
protected SelfReferenceEquivalencyAssertionOptions(FluentAssertions.Equivalency.IEquivalencyAssertionOptions defaults) { }
public bool CompareRecordsByValue { get; }
public bool? CompareRecordsByValue { get; }
public FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
protected FluentAssertions.Equivalency.OrderingRuleCollection OrderingRules { get; }
Expand Down
Expand Up @@ -857,7 +857,7 @@ namespace FluentAssertions.Equivalency
public interface IEquivalencyAssertionOptions
{
bool AllowInfiniteRecursion { get; }
bool CompareRecordsByValue { get; }
bool? CompareRecordsByValue { get; }
FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
FluentAssertions.Equivalency.CyclicReferenceHandling CyclicReferenceHandling { get; }
FluentAssertions.Equivalency.EnumEquivalencyHandling EnumEquivalencyHandling { get; }
Expand Down Expand Up @@ -1020,7 +1020,7 @@ namespace FluentAssertions.Equivalency
where TSelf : FluentAssertions.Equivalency.SelfReferenceEquivalencyAssertionOptions<TSelf>
{
protected SelfReferenceEquivalencyAssertionOptions(FluentAssertions.Equivalency.IEquivalencyAssertionOptions defaults) { }
public bool CompareRecordsByValue { get; }
public bool? CompareRecordsByValue { get; }
public FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
protected FluentAssertions.Equivalency.OrderingRuleCollection OrderingRules { get; }
Expand Down
Expand Up @@ -864,7 +864,7 @@ namespace FluentAssertions.Equivalency
public interface IEquivalencyAssertionOptions
{
bool AllowInfiniteRecursion { get; }
bool CompareRecordsByValue { get; }
bool? CompareRecordsByValue { get; }
FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
FluentAssertions.Equivalency.CyclicReferenceHandling CyclicReferenceHandling { get; }
FluentAssertions.Equivalency.EnumEquivalencyHandling EnumEquivalencyHandling { get; }
Expand Down Expand Up @@ -1027,7 +1027,7 @@ namespace FluentAssertions.Equivalency
where TSelf : FluentAssertions.Equivalency.SelfReferenceEquivalencyAssertionOptions<TSelf>
{
protected SelfReferenceEquivalencyAssertionOptions(FluentAssertions.Equivalency.IEquivalencyAssertionOptions defaults) { }
public bool CompareRecordsByValue { get; }
public bool? CompareRecordsByValue { get; }
public FluentAssertions.Equivalency.ConversionSelector ConversionSelector { get; }
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
protected FluentAssertions.Equivalency.OrderingRuleCollection OrderingRules { get; }
Expand Down
2 changes: 1 addition & 1 deletion Tests/Benchmarks/UsersOfGetClosedGenericInterfaces.cs
Expand Up @@ -72,7 +72,7 @@ private class Config : IEquivalencyAssertionOptions

public bool ExcludeNonBrowsableOnExpectation => throw new NotImplementedException();

public bool CompareRecordsByValue => throw new NotImplementedException();
public bool? CompareRecordsByValue => throw new NotImplementedException();

public ITraceWriter TraceWriter => throw new NotImplementedException();

Expand Down