Skip to content

Commit

Permalink
Merge 5f35832 into db4562b
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-VBFK committed Apr 14, 2022
2 parents db4562b + 5f35832 commit 1bf35a9
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Tests/FluentAssertions.Specs/Primitives/DateTimeAssertionSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,5 +2240,20 @@ public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_d
}

#endregion

[Fact]
public void Calling_equal_on_a_date_time_assertion_it_throws()
{
// Arrange
var expectation = 1.January(0001).At(0, 0, 45);
var subject = 1.January(0001).At(0, 0, 30);

// Act
Action action = () => subject.Should().BeLessThan(5.Seconds()).Equals(expectation);

// Assert
action.Should().Throw<NotSupportedException>()
.WithMessage("Calling Equals on Assertion classes is not supported.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2469,5 +2469,35 @@ public void When_a_value_is_one_of_the_specified_values_it_should_succeed_when_d
}

#endregion

[Fact]
public void Calling_equals_on_a_date_time_offset_throws_an_exception()
{
// Arrange
DateTimeOffset tmp = new DateTime(2016, 06, 03);
var subject = tmp.Should();

// Act
Action act = () => subject.Equals(new object());

// Assert
act.Should().Throw<NotSupportedException>()
.WithMessage("Calling Equals on Assertion classes is not supported.");
}

[Fact]
public void Calling_equals_on_a_date_time_offset_range_throws_an_exception()
{
// Arrange
var expectation = 1.January(0001).At(0, 0, 40).WithOffset(0.Hours());
var subject = 1.January(0001).At(0, 0, 30).WithOffset(0.Hours());

// Act
Action action = () => subject.Should().BeMoreThan(5.Seconds()).Equals(expectation);

// Assert
action.Should().Throw<NotSupportedException>()
.WithMessage("Calling Equals on Assertion classes is not supported.");
}
}
}
13 changes: 13 additions & 0 deletions Tests/FluentAssertions.Specs/Primitives/ObjectAssertionSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,19 @@ public class DataContractSerializableClassNotRestoringAllProperties

#endregion

[Fact]
public void Calling_equals_throws_an_exception()
{
// Arrange
var subject = new object();

// Act
Action act = () => subject.Should().Equals(new object());

// Assert
act.Should().Throw<NotSupportedException>()
.WithMessage("Calling Equals on Assertion classes is not supported.");
}
}

internal class DummyBaseClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ public void When_a_string_is_matched_against_null_it_should_throw_with_a_clear_e
.WithParameterName("wildcardPattern");
}

[Fact]
public void Null_does_not_match_to_any_string()
{
// Arrange
string subject = null;

// Act
Action act = () => subject.Should().Match("*");

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected subject to match *, but found <null>.");
}

[Fact]
public void When_a_string_is_matched_against_an_empty_string_it_should_throw_with_a_clear_explanation()
{
Expand Down

0 comments on commit 1bf35a9

Please sign in to comment.