-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
4,075 additions
and
3,968 deletions.
There are no files selected for viewing
537 changes: 537 additions & 0 deletions
537
Tests/FluentAssertions.Specs/Numeric/NumericAssertionSpecs.Be.cs
Large diffs are not rendered by default.
Oops, something went wrong.
898 changes: 898 additions & 0 deletions
898
Tests/FluentAssertions.Specs/Numeric/NumericAssertionSpecs.BeApproximately.cs
Large diffs are not rendered by default.
Oops, something went wrong.
1,479 changes: 1,479 additions & 0 deletions
1,479
Tests/FluentAssertions.Specs/Numeric/NumericAssertionSpecs.BeCloseTo.cs
Large diffs are not rendered by default.
Oops, something went wrong.
133 changes: 133 additions & 0 deletions
133
Tests/FluentAssertions.Specs/Numeric/NumericAssertionSpecs.BeGreaterThan.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Sdk; | ||
|
||
namespace FluentAssertions.Specs.Numeric; | ||
|
||
public partial class NumericAssertionSpecs | ||
{ | ||
public class BeGreaterThan | ||
{ | ||
[Fact] | ||
public void When_a_value_is_greater_than_smaller_value_it_should_not_throw() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int smallerValue = 1; | ||
|
||
// Act | ||
Action act = () => value.Should().BeGreaterThan(smallerValue); | ||
|
||
// Assert | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Fact] | ||
public void When_a_value_is_greater_than_greater_value_it_should_throw() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int greaterValue = 3; | ||
|
||
// Act | ||
Action act = () => value.Should().BeGreaterThan(greaterValue); | ||
|
||
// Assert | ||
act.Should().Throw<XunitException>(); | ||
} | ||
|
||
[Fact] | ||
public void When_a_value_is_greater_than_same_value_it_should_throw() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int sameValue = 2; | ||
|
||
// Act | ||
Action act = () => value.Should().BeGreaterThan(sameValue); | ||
|
||
// Assert | ||
act.Should().Throw<XunitException>(); | ||
} | ||
|
||
[Fact] | ||
public void When_a_value_is_greater_than_greater_value_it_should_throw_with_descriptive_message() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int greaterValue = 3; | ||
|
||
// Act | ||
Action act = () => | ||
value.Should().BeGreaterThan(greaterValue, "because we want to test the failure {0}", "message"); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<XunitException>() | ||
.WithMessage("Expected value to be greater than 3 because we want to test the failure message, but found 2."); | ||
} | ||
|
||
[Fact] | ||
public void NaN_is_never_greater_than_another_float() | ||
{ | ||
// Act | ||
Action act = () => float.NaN.Should().BeGreaterThan(0); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<XunitException>() | ||
.WithMessage("*NaN*"); | ||
} | ||
|
||
[Fact] | ||
public void A_float_cannot_be_greater_than_NaN() | ||
{ | ||
// Act | ||
Action act = () => 3.4F.Should().BeGreaterThan(float.NaN); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<ArgumentException>() | ||
.WithMessage("*NaN*"); | ||
} | ||
|
||
[Fact] | ||
public void NaN_is_never_greater_than_another_double() | ||
{ | ||
// Act | ||
Action act = () => double.NaN.Should().BeGreaterThan(0); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<XunitException>() | ||
.WithMessage("*NaN*"); | ||
} | ||
|
||
[Fact] | ||
public void A_double_can_never_be_greater_than_NaN() | ||
{ | ||
// Act | ||
Action act = () => 3.4D.Should().BeGreaterThan(double.NaN); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<ArgumentException>() | ||
.WithMessage("*NaN*"); | ||
} | ||
|
||
[Fact] | ||
public void When_a_nullable_numeric_null_value_is_not_greater_than_it_should_throw() | ||
{ | ||
// Arrange | ||
int? value = null; | ||
|
||
// Act | ||
Action act = () => value.Should().BeGreaterThan(0); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<XunitException>() | ||
.WithMessage("*null*"); | ||
} | ||
} | ||
} |
146 changes: 146 additions & 0 deletions
146
Tests/FluentAssertions.Specs/Numeric/NumericAssertionSpecs.BeGreaterThanOrEqualTo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Sdk; | ||
|
||
namespace FluentAssertions.Specs.Numeric; | ||
|
||
public partial class NumericAssertionSpecs | ||
{ | ||
public class BeGreaterThanOrEqualTo | ||
{ | ||
[Fact] | ||
public void When_a_value_is_greater_than_or_equal_to_smaller_value_it_should_not_throw() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int smallerValue = 1; | ||
|
||
// Act | ||
Action act = () => value.Should().BeGreaterThanOrEqualTo(smallerValue); | ||
|
||
// Assert | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Fact] | ||
public void When_a_value_is_greater_than_or_equal_to_same_value_it_should_not_throw() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int sameValue = 2; | ||
|
||
// Act | ||
Action act = () => value.Should().BeGreaterThanOrEqualTo(sameValue); | ||
|
||
// Assert | ||
act.Should().NotThrow(); | ||
} | ||
|
||
[Fact] | ||
public void When_a_value_is_greater_than_or_equal_to_greater_value_it_should_throw() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int greaterValue = 3; | ||
|
||
// Act | ||
Action act = () => value.Should().BeGreaterThanOrEqualTo(greaterValue); | ||
|
||
// Assert | ||
act.Should().Throw<XunitException>(); | ||
} | ||
|
||
[Fact] | ||
public void When_a_value_is_greater_than_or_equal_to_greater_value_it_should_throw_with_descriptive_message() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int greaterValue = 3; | ||
|
||
// Act | ||
Action act = | ||
() => value.Should() | ||
.BeGreaterThanOrEqualTo(greaterValue, "because we want to test the failure {0}", "message"); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<XunitException>() | ||
.WithMessage( | ||
"Expected value to be greater than or equal to 3 because we want to test the failure message, but found 2."); | ||
} | ||
|
||
[Fact] | ||
public void When_a_nullable_numeric_null_value_is_not_greater_than_or_equal_to_it_should_throw() | ||
{ | ||
// Arrange | ||
int? value = null; | ||
|
||
// Act | ||
Action act = () => value.Should().BeGreaterThanOrEqualTo(0); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<XunitException>() | ||
.WithMessage("*null*"); | ||
} | ||
|
||
[Fact] | ||
public void NaN_is_never_greater_than_or_equal_to_another_float() | ||
{ | ||
// Act | ||
Action act = () => float.NaN.Should().BeGreaterThanOrEqualTo(0); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<XunitException>() | ||
.WithMessage("*NaN*"); | ||
} | ||
|
||
[Fact] | ||
public void A_float_cannot_be_greater_than_or_equal_to_NaN() | ||
{ | ||
// Act | ||
Action act = () => 3.4F.Should().BeGreaterThanOrEqualTo(float.NaN); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<ArgumentException>() | ||
.WithMessage("*NaN*"); | ||
} | ||
|
||
[Fact] | ||
public void NaN_is_never_greater_or_equal_to_another_double() | ||
{ | ||
// Act | ||
Action act = () => double.NaN.Should().BeGreaterThanOrEqualTo(0); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<XunitException>() | ||
.WithMessage("*NaN*"); | ||
} | ||
|
||
[Fact] | ||
public void A_double_can_never_be_greater_or_equal_to_NaN() | ||
{ | ||
// Act | ||
Action act = () => 3.4D.Should().BeGreaterThanOrEqualTo(double.NaN); | ||
|
||
// Assert | ||
act | ||
.Should().Throw<ArgumentException>() | ||
.WithMessage("*NaN*"); | ||
} | ||
|
||
[Fact] | ||
public void Chaining_after_one_assertion() | ||
{ | ||
// Arrange | ||
int value = 2; | ||
int smallerValue = 1; | ||
|
||
// Act / Assert | ||
value.Should().BeGreaterThanOrEqualTo(smallerValue).And.Be(2); | ||
} | ||
} | ||
} |
Oops, something went wrong.