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

Structure assertions with nested classes instead of regions (Part 3) #1903

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
520 changes: 259 additions & 261 deletions Tests/FluentAssertions.Specs/Primitives/StringAssertionSpecs.Be.cs

Large diffs are not rendered by default.

198 changes: 98 additions & 100 deletions Tests/FluentAssertions.Specs/Primitives/StringAssertionSpecs.BeEmpty.cs
Expand Up @@ -9,110 +9,108 @@ namespace FluentAssertions.Specs.Primitives
/// </content>
public partial class StringAssertionSpecs
{
#region Be Empty

[Fact]
public void Should_succeed_when_asserting_empty_string_to_be_empty()
{
// Arrange
string actual = "";

// Act / Assert
actual.Should().BeEmpty();
}

[Fact]
public void Should_fail_when_asserting_non_empty_string_to_be_empty()
{
// Arrange
string actual = "ABC";

// Act
Action act = () => actual.Should().BeEmpty();

// Assert
act.Should().Throw<XunitException>();
}

[Fact]
public void Should_fail_with_descriptive_message_when_asserting_non_empty_string_to_be_empty()
public class BeEmpty
{
// Arrange
string actual = "ABC";

// Act
Action act = () => actual.Should().BeEmpty("because we want to test the failure {0}", "message");

// Assert
act.Should().Throw<XunitException>().WithMessage(
"Expected actual to be empty because we want to test the failure message, but found \"ABC\".");
[Fact]
public void Should_succeed_when_asserting_empty_string_to_be_empty()
{
// Arrange
string actual = "";

// Act / Assert
actual.Should().BeEmpty();
}

[Fact]
public void Should_fail_when_asserting_non_empty_string_to_be_empty()
{
// Arrange
string actual = "ABC";

// Act
Action act = () => actual.Should().BeEmpty();

// Assert
act.Should().Throw<XunitException>();
}

[Fact]
public void Should_fail_with_descriptive_message_when_asserting_non_empty_string_to_be_empty()
{
// Arrange
string actual = "ABC";

// Act
Action act = () => actual.Should().BeEmpty("because we want to test the failure {0}", "message");

// Assert
act.Should().Throw<XunitException>().WithMessage(
"Expected actual to be empty because we want to test the failure message, but found \"ABC\".");
}

[Fact]
public void When_checking_for_an_empty_string_and_it_is_null_it_should_throw()
{
// Arrange
string nullString = null;

// Act
Action act = () => nullString.Should().BeEmpty("because strings should never be {0}", "null");

// Assert
act.Should().Throw<XunitException>().WithMessage(
"Expected nullString to be empty because strings should never be null, but found <null>.");
}
}

[Fact]
public void When_checking_for_an_empty_string_and_it_is_null_it_should_throw()
public class NotBeEmpty
{
// Arrange
string nullString = null;

// Act
Action act = () => nullString.Should().BeEmpty("because strings should never be {0}", "null");

// Assert
act.Should().Throw<XunitException>().WithMessage(
"Expected nullString to be empty because strings should never be null, but found <null>.");
[Fact]
public void Should_succeed_when_asserting_non_empty_string_to_be_filled()
{
// Arrange
string actual = "ABC";

// Act / Assert
actual.Should().NotBeEmpty();
}

[Fact]
public void When_asserting_null_string_to_not_be_empty_it_should_succeed()
{
// Arrange
string actual = null;

// Act / Assert
actual.Should().NotBeEmpty();
}

[Fact]
public void Should_fail_when_asserting_empty_string_to_be_filled()
{
// Arrange
string actual = "";

// Act
Action act = () => actual.Should().NotBeEmpty();

// Assert
act.Should().Throw<XunitException>();
}

[Fact]
public void Should_fail_with_descriptive_message_when_asserting_empty_string_to_be_filled()
{
// Arrange
string actual = "";

// Act
Action act = () => actual.Should().NotBeEmpty("because we want to test the failure {0}", "message");

// Assert
act.Should().Throw<XunitException>().WithMessage(
"Did not expect actual to be empty because we want to test the failure message.");
}
}

#endregion

#region Not Be Empty

[Fact]
public void Should_succeed_when_asserting_non_empty_string_to_be_filled()
{
// Arrange
string actual = "ABC";

// Act / Assert
actual.Should().NotBeEmpty();
}

[Fact]
public void When_asserting_null_string_to_not_be_empty_it_should_succeed()
{
// Arrange
string actual = null;

// Act / Assert
actual.Should().NotBeEmpty();
}

[Fact]
public void Should_fail_when_asserting_empty_string_to_be_filled()
{
// Arrange
string actual = "";

// Act
Action act = () => actual.Should().NotBeEmpty();

// Assert
act.Should().Throw<XunitException>();
}

[Fact]
public void Should_fail_with_descriptive_message_when_asserting_empty_string_to_be_filled()
{
// Arrange
string actual = "";

// Act
Action act = () => actual.Should().NotBeEmpty("because we want to test the failure {0}", "message");

// Assert
act.Should().Throw<XunitException>().WithMessage(
"Did not expect actual to be empty because we want to test the failure message.");
}

#endregion
}
}