Skip to content

Commit ea3ce52

Browse files
committed
Seperate all Stream assertions into nested classes
1 parent bc43880 commit ea3ce52

File tree

2 files changed

+742
-726
lines changed

2 files changed

+742
-726
lines changed

Tests/FluentAssertions.Specs/Streams/BufferedStreamAssertionSpecs.cs

Lines changed: 80 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -11,103 +11,105 @@ namespace FluentAssertions.Specs.Streams
1111
public class BufferedStreamAssertionSpecs
1212
{
1313
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1
14-
#region HaveBufferSize / NotHaveBufferSize
15-
16-
[Fact]
17-
public void When_a_stream_has_the_expected_buffer_size_it_should_succeed()
14+
public class HaveBufferSize
1815
{
19-
// Arrange
20-
using var stream = new BufferedStream(new MemoryStream(), 10);
16+
[Fact]
17+
public void When_a_stream_has_the_expected_buffer_size_it_should_succeed()
18+
{
19+
// Arrange
20+
using var stream = new BufferedStream(new MemoryStream(), 10);
2121

22-
// Act
23-
Action act = () =>
24-
stream.Should().HaveBufferSize(10);
22+
// Act
23+
Action act = () =>
24+
stream.Should().HaveBufferSize(10);
2525

26-
// Assert
27-
act.Should().NotThrow();
28-
}
29-
30-
[Fact]
31-
public void When_a_stream_has_an_unexpected_buffer_size_should_fail()
32-
{
33-
// Arrange
34-
using var stream = new BufferedStream(new MemoryStream(), 1);
26+
// Assert
27+
act.Should().NotThrow();
28+
}
3529

36-
// Act
37-
Action act = () =>
38-
stream.Should().HaveBufferSize(10, "we want to test the failure {0}", "message");
30+
[Fact]
31+
public void When_a_stream_has_an_unexpected_buffer_size_should_fail()
32+
{
33+
// Arrange
34+
using var stream = new BufferedStream(new MemoryStream(), 1);
3935

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

45-
[Fact]
46-
public void When_null_have_buffer_size_should_fail()
47-
{
48-
// Arrange
49-
BufferedStream stream = null;
40+
// Assert
41+
act.Should().Throw<XunitException>()
42+
.WithMessage("Expected the buffer size of stream to be 10 *failure message*, but it was 1.");
43+
}
5044

51-
// Act
52-
Action act = () =>
45+
[Fact]
46+
public void When_null_have_buffer_size_should_fail()
5347
{
54-
using var _ = new AssertionScope();
55-
stream.Should().HaveBufferSize(10, "we want to test the failure {0}", "message");
56-
};
57-
58-
// Assert
59-
act.Should().Throw<XunitException>()
60-
.WithMessage("Expected the buffer size of stream to be 10 *failure message*, but found a <null> reference.");
48+
// Arrange
49+
BufferedStream stream = null;
50+
51+
// Act
52+
Action act = () =>
53+
{
54+
using var _ = new AssertionScope();
55+
stream.Should().HaveBufferSize(10, "we want to test the failure {0}", "message");
56+
};
57+
58+
// Assert
59+
act.Should().Throw<XunitException>()
60+
.WithMessage("Expected the buffer size of stream to be 10 *failure message*, but found a <null> reference.");
61+
}
6162
}
6263

63-
[Fact]
64-
public void When_a_stream_does_not_have_an_unexpected_buffer_size_it_should_succeed()
64+
public class NotHaveBufferSize
6565
{
66-
// Arrange
67-
using var stream = new BufferedStream(new MemoryStream(), 1);
66+
[Fact]
67+
public void When_a_stream_does_not_have_an_unexpected_buffer_size_it_should_succeed()
68+
{
69+
// Arrange
70+
using var stream = new BufferedStream(new MemoryStream(), 1);
6871

69-
// Act
70-
Action act = () =>
71-
stream.Should().NotHaveBufferSize(10);
72+
// Act
73+
Action act = () =>
74+
stream.Should().NotHaveBufferSize(10);
7275

73-
// Assert
74-
act.Should().NotThrow();
75-
}
76+
// Assert
77+
act.Should().NotThrow();
78+
}
7679

77-
[Fact]
78-
public void When_a_stream_does_have_the_unexpected_buffer_size_it_should_fail()
79-
{
80-
// Arrange
81-
using var stream = new BufferedStream(new MemoryStream(), 10);
80+
[Fact]
81+
public void When_a_stream_does_have_the_unexpected_buffer_size_it_should_fail()
82+
{
83+
// Arrange
84+
using var stream = new BufferedStream(new MemoryStream(), 10);
8285

83-
// Act
84-
Action act = () =>
85-
stream.Should().NotHaveBufferSize(10, "we want to test the failure {0}", "message");
86+
// Act
87+
Action act = () =>
88+
stream.Should().NotHaveBufferSize(10, "we want to test the failure {0}", "message");
8689

87-
// Assert
88-
act.Should().Throw<XunitException>()
89-
.WithMessage("Expected the buffer size of stream not to be 10 *failure message*, but it was.");
90-
}
90+
// Assert
91+
act.Should().Throw<XunitException>()
92+
.WithMessage("Expected the buffer size of stream not to be 10 *failure message*, but it was.");
93+
}
9194

92-
[Fact]
93-
public void When_null_not_have_buffer_size_should_fail()
94-
{
95-
// Arrange
96-
BufferedStream stream = null;
97-
98-
// Act
99-
Action act = () =>
95+
[Fact]
96+
public void When_null_not_have_buffer_size_should_fail()
10097
{
101-
using var _ = new AssertionScope();
102-
stream.Should().NotHaveBufferSize(10, "we want to test the failure {0}", "message");
103-
};
104-
105-
// Assert
106-
act.Should().Throw<XunitException>()
107-
.WithMessage("Expected the buffer size of stream not to be 10 *failure message*, but found a <null> reference.");
98+
// Arrange
99+
BufferedStream stream = null;
100+
101+
// Act
102+
Action act = () =>
103+
{
104+
using var _ = new AssertionScope();
105+
stream.Should().NotHaveBufferSize(10, "we want to test the failure {0}", "message");
106+
};
107+
108+
// Assert
109+
act.Should().Throw<XunitException>()
110+
.WithMessage("Expected the buffer size of stream not to be 10 *failure message*, but found a <null> reference.");
111+
}
108112
}
109-
110-
#endregion
111113
#endif
112114
}
113115
}

0 commit comments

Comments
 (0)