Skip to content

Commit 3dd40d7

Browse files
committed
BUGFIX: Issue #25
1 parent a805fbe commit 3dd40d7

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ I deemed this renaming necessary as the `Fakes` suffix collides with [Microsoft
3232

3333
## History
3434

35+
### [Version 1.3.1 - 2020/11/23](https://github.com/addupsolutions/AddUp.FakeRabbitMQ/releases/tag/v1.3.1)
36+
37+
* BUGFIX: #25. Now it is possible to close a `Channel` after its connection was closed without the `Channel.Close` method throwing (this is consistent with how **RabbitMQ.Client** behaves).
38+
3539
### [Version 1.3.0 - 2020/11/09](https://github.com/addupsolutions/AddUp.FakeRabbitMQ/releases/tag/v1.3.0)
3640

3741
Most of the work in this release was contributed by @inbarbarkai. Thanks to him!
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
using Xunit;
3+
4+
namespace AddUp.RabbitMQ.Fakes.issues
5+
{
6+
[ExcludeFromCodeCoverage]
7+
public class CloseModelTests
8+
{
9+
// This ensures issue #25 is fixed
10+
[Fact]
11+
public void Closing_a_model_after_disconnection_should_not_throw()
12+
{
13+
var factory = new FakeConnectionFactory();
14+
var connection = factory.CreateConnection();
15+
16+
var model = connection.CreateModel();
17+
connection.Close();
18+
model.Close();
19+
20+
Assert.True(true); // If we didn't throw, we reached this point.
21+
}
22+
}
23+
}

src/AddUp.FakeRabbitMQ/FakeModel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal sealed class FakeModel : IModel
4545

4646
public void Dispose()
4747
{
48-
if (IsOpen) Abort(); // Abort rather than Close because we do not want Dispose to throw
48+
if (IsOpen) Abort();
4949
}
5050

5151
public IEnumerable<RabbitMessage> GetMessagesPublishedToExchange(string exchange)
@@ -410,7 +410,6 @@ private void Close(ShutdownEventArgs reason, bool abort)
410410
{
411411
try
412412
{
413-
if (IsClosed) throw new AlreadyClosedException(reason);
414413
CloseReason = reason;
415414
ModelShutdown?.Invoke(this, reason);
416415
}

0 commit comments

Comments
 (0)