Skip to content

marcusber/AddUp.FakeRabbitMQ

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AddUp.FakeRabbitMQ

Build Quality Gate Status Coverage NuGet

Important Notice

On 2020/10/04, and starting with version 1.2.3, AddUp.RabbitMQ.Fakes was renamed to AddUp.FakeRabbitMQ. This concerns:

However, the root namespace remains (for compatibility purpose) AddUp.RabbitMQ.Fakes.

I deemed this renaming necessary as the Fakes suffix collides with Microsoft Fakes product. Because the assembly name ends with .Fakes, several unit-test related tools consider it not to be a real assembly but rather something generated by Microsoft Fakes.

About

AddUp.FakeRabbitMQ is a fork of https://github.com/Parametric/RabbitMQ.Fakes. Thanks to the folks over there for their work without which our own version would probably never have been possible.

AddUp.FakeRabbitMQ provides fake implementations of the RabbitMQ.Client interfaces (see https://www.nuget.org/packages/RabbitMQ.Client for the nuget package and https://github.com/rabbitmq/rabbitmq-dotnet-client for its source code). They are intended to be used for testing so that unit tests that depend on RabbitMQ can be executed fully in memory withouth needing an external RabbitMQ server.

AddUp.FakeRabbitMQ builds on top of the original project:

  • Targets .NET Standard 2.0
  • Supports Default, Direct, Topic and Fanout exchange types.
    • NB: Headers exchange type is not supported; however, it won't throw (it is implemented the same way as the Fanout type)

Hall of fame

Thanks to all the contributors:

History

Versions 1.x are based on RabbitMQ .NET client Version 5.x

Versions 2.x are based on RabbitMQ .NET client Version 6.x

  • Updated RabbitMQ.Client to version 6.5.0

Two contributions by @patrikwlund:

  • Better compliance: No more unique singleton-based connection. See PR #122 for details.
  • New feature: by passing a boolean to the constructor of AddUp.RabbitMQ.Fakes.RabbitServer, one can opt into using blocking delivery (the default remains non-blocking). This helps simplifying unit tests in scenarios where one is not interested in simulating a real RabbitMQ behavior (avoids asynchronous waiting for messages delivery). See PR #123 for details.

Another pair of improvements by @Quogu:

  • Better compliance: A unique consumer tag is now generated when the calling code does not provide any. See PR #117 for details.
  • Better underlying delivery model (using Tasks). Should reduce deadlock issues in Test code. See PR #118 for details.
  • A few types in the implementation of the fake server are now public. This may prove useful in order to examine the inners of the server for tests purpose. See PR #115 for details.
  • Better compliance: newly declared queues are now bound to RabbitMQ's default exchange. See PR #116 for details.
  • Updated RabbitMQ.Client to version 6.4.0
  • Based on RabbitMQ.Client version 6.2.4
  • Updated dependencies (obviously except for RabbitMQ.Client that is still version 5.2.0)

Mostly cleanup of the codebase as preparatory work for the v6 client implementation

  • Code cleanup:
    • Removed useless overloads and members in FakeModel.
    • Refactored Unit Tests (split IModel tests into several classes, got rid of the Arrange, Act and Assert comments, renamed methods) + added a few ones.
  • No-op implementation in IModel.TxSelect, IModel.TxCommit and IModel.TxRollback instead of throwing.
  • Implemented IModel.MessageCount(queue) and IModel.ConsumerCount(queue) based on QueueDeclarePassive.
  • IModel.QueuePurge now returns the number of purged messages.

This release merges the PR by @inbarbarkai. They are one year-old, and I'm ashamed it took me this long to merge them. Because I'm now watching the repository, I should need less time to react in the future... Once again thanks for his contribution.

  • BUGFIX: #30. QueueDeclarePassive now throws if the queue does not exist. Similarly, ExchangeDeclarePassive throws if the exchange does not exist.
  • FEATURE: #29. Support for the Alternate Exchange Feature.
  • BUGFIX: #28. DefaultBasicConsumer.IsRunning property is now correctly returning true/false.
  • BUGFIX: #27. It was impossible to create a connection after having created and closed a previous connection.
  • 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).

Most of the work in this release was contributed by @inbarbarkai. Thanks to him!

  • As suggested by @inbarbarkai: Basic support for IModel.ConfirmSelect and the IModel.WaitForConfirms* family.
  • Support for IModel.CreateBasicPublishBatch was added thanks to PR #21 by @inbarbarkai.
  • Consumers that implement both IBasicConsumer and IAsyncBasicConsumer are correctly handled by IModel.BasicConsume and IModel.BasicCancel thanks to PR #23 by @inbarbarkai.
  • Renamed from AddUp.RabbitMQ.Fakes to AddUp.FakeRabbitMQ.
  • BUGFIX: Closing a connection could throw if owned models were closed before.
  • Updated to RabbitMQ.Client to version 5.2.0
  • First released version of AddUp.RabbitMQ.Fakes. Based on RabbitMQ.Client version 5.1.2
  • NB: the version starts at 1.2.0 so as not to collide with previous internal versions.

License

This work is provided under the terms of the MIT License.

About

Fakes used for testing RabbitMQ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%