Skip to content

Commit

Permalink
Seperate all Stream assertions into nested classes
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-VBFK committed Apr 23, 2022
1 parent 99edce6 commit d8dac87
Show file tree
Hide file tree
Showing 2 changed files with 742 additions and 726 deletions.
158 changes: 80 additions & 78 deletions Tests/FluentAssertions.Specs/Streams/BufferedStreamAssertionSpecs.cs
Expand Up @@ -11,103 +11,105 @@ namespace FluentAssertions.Specs.Streams
public class BufferedStreamAssertionSpecs
{
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1
#region HaveBufferSize / NotHaveBufferSize

[Fact]
public void When_a_stream_has_the_expected_buffer_size_it_should_succeed()
public class HaveBufferSize
{
// Arrange
using var stream = new BufferedStream(new MemoryStream(), 10);
[Fact]
public void When_a_stream_has_the_expected_buffer_size_it_should_succeed()
{
// Arrange
using var stream = new BufferedStream(new MemoryStream(), 10);

// Act
Action act = () =>
stream.Should().HaveBufferSize(10);
// Act
Action act = () =>
stream.Should().HaveBufferSize(10);

// Assert
act.Should().NotThrow();
}

[Fact]
public void When_a_stream_has_an_unexpected_buffer_size_should_fail()
{
// Arrange
using var stream = new BufferedStream(new MemoryStream(), 1);
// Assert
act.Should().NotThrow();
}

// Act
Action act = () =>
stream.Should().HaveBufferSize(10, "we want to test the failure {0}", "message");
[Fact]
public void When_a_stream_has_an_unexpected_buffer_size_should_fail()
{
// Arrange
using var stream = new BufferedStream(new MemoryStream(), 1);

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected the buffer size of stream to be 10 *failure message*, but it was 1.");
}
// Act
Action act = () =>
stream.Should().HaveBufferSize(10, "we want to test the failure {0}", "message");

[Fact]
public void When_null_have_buffer_size_should_fail()
{
// Arrange
BufferedStream stream = null;
// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected the buffer size of stream to be 10 *failure message*, but it was 1.");
}

// Act
Action act = () =>
[Fact]
public void When_null_have_buffer_size_should_fail()
{
using var _ = new AssertionScope();
stream.Should().HaveBufferSize(10, "we want to test the failure {0}", "message");
};

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected the buffer size of stream to be 10 *failure message*, but found a <null> reference.");
// Arrange
BufferedStream stream = null;

// Act
Action act = () =>
{
using var _ = new AssertionScope();
stream.Should().HaveBufferSize(10, "we want to test the failure {0}", "message");
};

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected the buffer size of stream to be 10 *failure message*, but found a <null> reference.");
}
}

[Fact]
public void When_a_stream_does_not_have_an_unexpected_buffer_size_it_should_succeed()
public class NotHaveBufferSize
{
// Arrange
using var stream = new BufferedStream(new MemoryStream(), 1);
[Fact]
public void When_a_stream_does_not_have_an_unexpected_buffer_size_it_should_succeed()
{
// Arrange
using var stream = new BufferedStream(new MemoryStream(), 1);

// Act
Action act = () =>
stream.Should().NotHaveBufferSize(10);
// Act
Action act = () =>
stream.Should().NotHaveBufferSize(10);

// Assert
act.Should().NotThrow();
}
// Assert
act.Should().NotThrow();
}

[Fact]
public void When_a_stream_does_have_the_unexpected_buffer_size_it_should_fail()
{
// Arrange
using var stream = new BufferedStream(new MemoryStream(), 10);
[Fact]
public void When_a_stream_does_have_the_unexpected_buffer_size_it_should_fail()
{
// Arrange
using var stream = new BufferedStream(new MemoryStream(), 10);

// Act
Action act = () =>
stream.Should().NotHaveBufferSize(10, "we want to test the failure {0}", "message");
// Act
Action act = () =>
stream.Should().NotHaveBufferSize(10, "we want to test the failure {0}", "message");

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected the buffer size of stream not to be 10 *failure message*, but it was.");
}
// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected the buffer size of stream not to be 10 *failure message*, but it was.");
}

[Fact]
public void When_null_not_have_buffer_size_should_fail()
{
// Arrange
BufferedStream stream = null;

// Act
Action act = () =>
[Fact]
public void When_null_not_have_buffer_size_should_fail()
{
using var _ = new AssertionScope();
stream.Should().NotHaveBufferSize(10, "we want to test the failure {0}", "message");
};

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected the buffer size of stream not to be 10 *failure message*, but found a <null> reference.");
// Arrange
BufferedStream stream = null;

// Act
Action act = () =>
{
using var _ = new AssertionScope();
stream.Should().NotHaveBufferSize(10, "we want to test the failure {0}", "message");
};

// Assert
act.Should().Throw<XunitException>()
.WithMessage("Expected the buffer size of stream not to be 10 *failure message*, but found a <null> reference.");
}
}

#endregion
#endif
}
}

0 comments on commit d8dac87

Please sign in to comment.