Skip to content

Commit

Permalink
Merge 8960b89 into cba483e
Browse files Browse the repository at this point in the history
  • Loading branch information
nycdotnet committed Oct 6, 2022
2 parents cba483e + 8960b89 commit e4fa37c
Show file tree
Hide file tree
Showing 44 changed files with 351 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public GenericCollectionAssertions(TCollection actualValue)
}
}

#pragma warning disable CS0659 // Ignore not overriding Object.GetHashCode()
#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals
[DebuggerNonUserCode]
public class GenericCollectionAssertions<TCollection, T, TAssertions> :
ReferenceTypeAssertions<TCollection, TAssertions>
Expand Down Expand Up @@ -3449,6 +3451,10 @@ private AndConstraint<TAssertions> NotBeInOrder(IComparer<T> comparer, SortOrder
return new AndConstraint<TAssertions>((TAssertions)this);
}

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean BeSameAs() or Equal() instead?");

private static int IndexOf(IList<T> items, T item, int startIndex)
{
Func<T, T, bool> comparer = ObjectExtensions.GetComparer<T>();
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Numeric/NumericAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public AndConstraint<TAssertions> NotBeOfType(Type unexpectedType, string becaus

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");

private protected virtual bool IsNaN(T value) => false;

Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/BooleanAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ public AndConstraint<TAssertions> NotBe(bool unexpected, string because = "", pa

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/DateOnlyAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public AndConstraint<TAssertions> BeOneOf(IEnumerable<DateOnly?> validValues, st

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}

#endif
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/DateTimeAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -925,5 +925,5 @@ public AndConstraint<TAssertions> BeIn(DateTimeKind expectedKind, string because

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
Original file line number Diff line number Diff line change
Expand Up @@ -1094,5 +1094,5 @@ public AndConstraint<TAssertions> BeOneOf(IEnumerable<DateTimeOffset?> validValu

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ private static string PositionRelativeToTarget(DateTimeOffset actual, DateTimeOf

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Before() or After() instead?");
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/DateTimeRangeAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,5 @@ private static string PositionRelativeToTarget(DateTime actual, DateTime target)

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Before() or After() instead?");
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/EnumAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,5 @@ private static string GetName<T>(T @enum)

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/GuidAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,5 @@ public AndConstraint<TAssertions> NotBe(Guid unexpected, string because = "", pa

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
6 changes: 6 additions & 0 deletions Src/FluentAssertions/Primitives/ObjectAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public ObjectAssertions(object value)
}
}

#pragma warning disable CS0659 // Ignore not overriding Object.GetHashCode()
#pragma warning disable CA1065 // Ignore throwing NotSupportedException from Equals
/// <summary>
/// Contains a number of methods to assert that a <typeparamref name="TSubject"/> is in the expected state.
/// </summary>
Expand Down Expand Up @@ -220,6 +222,10 @@ public AndConstraint<TAssertions> NotBe(TSubject unexpected, string because = ""
return new AndConstraint<TAssertions>((TAssertions)this);
}

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() or BeSameAs() instead?");

/// <summary>
/// Returns the type of the subject the assertion applies on.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/ReferenceTypeAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,5 +422,5 @@ public AndConstraint<TAssertions> NotBeAssignableTo(Type type, string because =

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,5 @@ public AndConstraint<TAssertions> BeGreaterThan(TimeSpan expected, string becaus

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Primitives/TimeOnlyAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public AndConstraint<TAssertions> BeOneOf(IEnumerable<TimeOnly?> validValues, st

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,5 @@ public AndConstraint<ExecutionTimeAssertions> BeCloseTo(TimeSpan expectedDuratio

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean BeLessThanOrEqualTo() or BeGreaterThanOrEqualTo() instead?");
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected TaskCompletionSourceAssertionsBase(IClock clock)

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean CompleteWithinAsync() instead?");

/// <summary>
/// Monitors the specified task whether it completes withing the remaining time span.
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Types/MethodInfoSelectorAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,5 @@ private static string GetDescriptionsFor(IEnumerable<MethodInfo> methods)

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,5 @@ private static string GetDescriptionsFor(IEnumerable<PropertyInfo> properties)

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Types/TypeSelectorAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,5 +477,5 @@ private static string GetDescriptionFor(Type type)

/// <inheritdoc/>
public override bool Equals(object obj) =>
throw new NotSupportedException("Calling Equals on Assertion classes is not supported.");
throw new NotSupportedException("Equals is not part of Fluent Assertions. Did you mean Be() instead?");
}
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ namespace FluentAssertions.Collections
public FluentAssertions.AndConstraint<TAssertions> Equal(params T[] elements) { }
public FluentAssertions.AndConstraint<TAssertions> Equal(System.Collections.Generic.IEnumerable<T> expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> Equal<TExpectation>(System.Collections.Generic.IEnumerable<TExpectation> expectation, System.Func<T, TExpectation, bool> equalityComparison, string because = "", params object[] becauseArgs) { }
public override bool Equals(object obj) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCount(int expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCount(System.Linq.Expressions.Expression<System.Func<int, bool>> countPredicate, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCountGreaterOrEqualTo(int expected, string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2100,6 +2101,7 @@ namespace FluentAssertions.Primitives
public FluentAssertions.AndConstraint<TAssertions> Be(TSubject expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expectation, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expectation, System.Func<FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>, FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>> config, string because = "", params object[] becauseArgs) { }
public override bool Equals(object obj) { }
public FluentAssertions.AndConstraint<TAssertions> NotBe(TSubject unexpected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(TExpectation unexpected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(TExpectation unexpected, System.Func<FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>, FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>> config, string because = "", params object[] becauseArgs) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ namespace FluentAssertions.Collections
public FluentAssertions.AndConstraint<TAssertions> Equal(params T[] elements) { }
public FluentAssertions.AndConstraint<TAssertions> Equal(System.Collections.Generic.IEnumerable<T> expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> Equal<TExpectation>(System.Collections.Generic.IEnumerable<TExpectation> expectation, System.Func<T, TExpectation, bool> equalityComparison, string because = "", params object[] becauseArgs) { }
public override bool Equals(object obj) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCount(int expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCount(System.Linq.Expressions.Expression<System.Func<int, bool>> countPredicate, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCountGreaterOrEqualTo(int expected, string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2184,6 +2185,7 @@ namespace FluentAssertions.Primitives
public FluentAssertions.AndConstraint<TAssertions> Be(TSubject expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expectation, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expectation, System.Func<FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>, FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>> config, string because = "", params object[] becauseArgs) { }
public override bool Equals(object obj) { }
public FluentAssertions.AndConstraint<TAssertions> NotBe(TSubject unexpected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(TExpectation unexpected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(TExpectation unexpected, System.Func<FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>, FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>> config, string because = "", params object[] becauseArgs) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ namespace FluentAssertions.Collections
public FluentAssertions.AndConstraint<TAssertions> Equal(params T[] elements) { }
public FluentAssertions.AndConstraint<TAssertions> Equal(System.Collections.Generic.IEnumerable<T> expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> Equal<TExpectation>(System.Collections.Generic.IEnumerable<TExpectation> expectation, System.Func<T, TExpectation, bool> equalityComparison, string because = "", params object[] becauseArgs) { }
public override bool Equals(object obj) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCount(int expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCount(System.Linq.Expressions.Expression<System.Func<int, bool>> countPredicate, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCountGreaterOrEqualTo(int expected, string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2100,6 +2101,7 @@ namespace FluentAssertions.Primitives
public FluentAssertions.AndConstraint<TAssertions> Be(TSubject expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expectation, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expectation, System.Func<FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>, FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>> config, string because = "", params object[] becauseArgs) { }
public override bool Equals(object obj) { }
public FluentAssertions.AndConstraint<TAssertions> NotBe(TSubject unexpected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(TExpectation unexpected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(TExpectation unexpected, System.Func<FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>, FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>> config, string because = "", params object[] becauseArgs) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ namespace FluentAssertions.Collections
public FluentAssertions.AndConstraint<TAssertions> Equal(params T[] elements) { }
public FluentAssertions.AndConstraint<TAssertions> Equal(System.Collections.Generic.IEnumerable<T> expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> Equal<TExpectation>(System.Collections.Generic.IEnumerable<TExpectation> expectation, System.Func<T, TExpectation, bool> equalityComparison, string because = "", params object[] becauseArgs) { }
public override bool Equals(object obj) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCount(int expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCount(System.Linq.Expressions.Expression<System.Func<int, bool>> countPredicate, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> HaveCountGreaterOrEqualTo(int expected, string because = "", params object[] becauseArgs) { }
Expand Down Expand Up @@ -2100,6 +2101,7 @@ namespace FluentAssertions.Primitives
public FluentAssertions.AndConstraint<TAssertions> Be(TSubject expected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expectation, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> BeEquivalentTo<TExpectation>(TExpectation expectation, System.Func<FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>, FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>> config, string because = "", params object[] becauseArgs) { }
public override bool Equals(object obj) { }
public FluentAssertions.AndConstraint<TAssertions> NotBe(TSubject unexpected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(TExpectation unexpected, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<TAssertions> NotBeEquivalentTo<TExpectation>(TExpectation unexpected, System.Func<FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>, FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation>> config, string because = "", params object[] becauseArgs) { }
Expand Down
Loading

0 comments on commit e4fa37c

Please sign in to comment.