Change names of "OrEqualTo" assertion methods by gliljas · Pull Request #1673 · fluentassertions/fluentassertions · GitHub
Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Src/FluentAssertions/Collections/GenericCollectionAssertions.cs
15 changes: 11 additions & 4 deletions Src/FluentAssertions/Numeric/ComparableTypeAssertions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using FluentAssertions.Common;
using FluentAssertions.Equivalency;
Expand Down Expand Up @@ -233,16 +234,19 @@ public AndConstraint<TAssertions> BeLessThan(T expected, string because = "", pa
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public AndConstraint<TAssertions> BeLessOrEqualTo(T expected, string because = "", params object[] becauseArgs)
public AndConstraint<TAssertions> BeLessThanOrEqualTo(T expected, string because = "", params object[] becauseArgs)
{
Execute.Assertion
.ForCondition(Subject.CompareTo(expected) <= Equal)
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:object} {0} to be less or equal to {1}{reason}.", Subject, expected);
.FailWith("Expected {context:object} {0} to be less than or equal to {1}{reason}.", Subject, expected);

return new AndConstraint<TAssertions>((TAssertions)this);
}

[EditorBrowsable(EditorBrowsableState.Never)]
public AndConstraint<TAssertions> BeLessOrEqualTo(T expected, string because = "", params object[] becauseArgs) => BeLessThanOrEqualTo(expected, because, becauseArgs);

/// <summary>
/// Asserts that the subject is greater than another object according to its implementation of <see cref="IComparable{T}"/>.
/// </summary>
Expand Down Expand Up @@ -279,16 +283,19 @@ public AndConstraint<TAssertions> BeGreaterThan(T expected, string because = "",
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public AndConstraint<TAssertions> BeGreaterOrEqualTo(T expected, string because = "", params object[] becauseArgs)
public AndConstraint<TAssertions> BeGreaterThanOrEqualTo(T expected, string because = "", params object[] becauseArgs)
{
Execute.Assertion
.ForCondition(Subject.CompareTo(expected) >= Equal)
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:object} {0} to be greater or equal to {1}{reason}.", Subject, expected);
.FailWith("Expected {context:object} {0} to be greater than or equal to {1}{reason}.", Subject, expected);

return new AndConstraint<TAssertions>((TAssertions)this);
}

[EditorBrowsable(EditorBrowsableState.Never)]
public AndConstraint<TAssertions> BeGreaterOrEqualTo(T expected, string because = "", params object[] becauseArgs) => BeGreaterThanOrEqualTo(expected, because, becauseArgs);

/// <summary>
/// Asserts that a value is within a range.
/// </summary>
Expand Down
15 changes: 11 additions & 4 deletions Src/FluentAssertions/Numeric/NumericAssertions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
Expand Down Expand Up @@ -201,17 +202,20 @@ public AndConstraint<TAssertions> BeLessThan(T expected, string because = "", pa
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public AndConstraint<TAssertions> BeLessOrEqualTo(T expected, string because = "",
public AndConstraint<TAssertions> BeLessThanOrEqualTo(T expected, string because = "",
params object[] becauseArgs)
{
Execute.Assertion
.ForCondition(Subject.HasValue && Subject.Value.CompareTo(expected) <= 0)
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:value} to be less or equal to {0}{reason}, but found {1}.", expected, Subject);
.FailWith("Expected {context:value} to be less than or equal to {0}{reason}, but found {1}.", expected, Subject);

return new AndConstraint<TAssertions>((TAssertions)this);
}

[EditorBrowsable(EditorBrowsableState.Never)]
public AndConstraint<TAssertions> BeLessOrEqualTo(T expected, string because = "", params object[] becauseArgs) => BeLessThanOrEqualTo(expected, because, becauseArgs);

/// <summary>
/// Asserts that the numeric value is greater than the specified <paramref name="expected"/> value.
/// </summary>
Expand Down Expand Up @@ -245,17 +249,20 @@ public AndConstraint<TAssertions> BeGreaterThan(T expected, string because = "",
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public AndConstraint<TAssertions> BeGreaterOrEqualTo(T expected, string because = "",
public AndConstraint<TAssertions> BeGreaterThanOrEqualTo(T expected, string because = "",
params object[] becauseArgs)
{
Execute.Assertion
.ForCondition(Subject.HasValue && Subject.Value.CompareTo(expected) >= 0)
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:value} to be greater or equal to {0}{reason}, but found {1}.", expected, Subject);
.FailWith("Expected {context:value} to be greater than or equal to {0}{reason}, but found {1}.", expected, Subject);

return new AndConstraint<TAssertions>((TAssertions)this);
}

[EditorBrowsable(EditorBrowsableState.Never)]
public AndConstraint<TAssertions> BeGreaterOrEqualTo(T expected, string because = "", params object[] becauseArgs) => BeGreaterThanOrEqualTo(expected, because, becauseArgs);

/// <summary>
/// Asserts that a value is within a range.
/// </summary>
Expand Down
15 changes: 11 additions & 4 deletions Src/FluentAssertions/Primitives/SimpleTimeSpanAssertions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using FluentAssertions.Execution;

Expand Down Expand Up @@ -175,11 +176,11 @@ public AndConstraint<TAssertions> BeLessThan(TimeSpan expected, string because =
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public AndConstraint<TAssertions> BeLessOrEqualTo(TimeSpan expected, string because = "", params object[] becauseArgs)
public AndConstraint<TAssertions> BeLessThanOrEqualTo(TimeSpan expected, string because = "", params object[] becauseArgs)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.WithExpectation("Expected {context:time} to be less or equal to {0}{reason}, ", expected)
.WithExpectation("Expected {context:time} to be less than or equal to {0}{reason}, ", expected)
.ForCondition(Subject.HasValue)
.FailWith("but found <null>.")
.Then
Expand All @@ -191,6 +192,9 @@ public AndConstraint<TAssertions> BeLessOrEqualTo(TimeSpan expected, string beca
return new AndConstraint<TAssertions>((TAssertions)this);
}

[EditorBrowsable(EditorBrowsableState.Never)]
public AndConstraint<TAssertions> BeLessOrEqualTo(TimeSpan expected, string because = "", params object[] becauseArgs) => BeLessThanOrEqualTo(expected, because, becauseArgs);

/// <summary>
/// Asserts that the time difference of the current <see cref="TimeSpan"/> is greater than the
/// specified <paramref name="expected"/> time.
Expand Down Expand Up @@ -231,12 +235,12 @@ public AndConstraint<TAssertions> BeGreaterThan(TimeSpan expected, string becaus
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public AndConstraint<TAssertions> BeGreaterOrEqualTo(TimeSpan expected, string because = "",
public AndConstraint<TAssertions> BeGreaterThanOrEqualTo(TimeSpan expected, string because = "",
params object[] becauseArgs)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.WithExpectation("Expected {context:time} to be greater or equal to {0}{reason}, ", expected)
.WithExpectation("Expected {context:time} to be greater than or equal to {0}{reason}, ", expected)
.ForCondition(Subject.HasValue)
.FailWith("but found <null>.")
.Then
Expand All @@ -248,6 +252,9 @@ public AndConstraint<TAssertions> BeGreaterOrEqualTo(TimeSpan expected, string b
return new AndConstraint<TAssertions>((TAssertions)this);
}

[EditorBrowsable(EditorBrowsableState.Never)]
public AndConstraint<TAssertions> BeGreaterOrEqualTo(TimeSpan expected, string because = "", params object[] becauseArgs) => BeGreaterThanOrEqualTo(expected, because, becauseArgs);

/// <summary>
/// Asserts that the current <see cref="TimeSpan"/> is within the specified time
/// from the specified <paramref name="nearbyTime"/> value.
Expand Down
19 changes: 13 additions & 6 deletions Src/FluentAssertions/Specialized/ExecutionTimeAssertions.cs
Loading