Skip to content

KyleCrowley/RabbitMQ.Fakes.DotNetStandard

 
 

Repository files navigation

RabbitMQ.Fakes.DotNetStandard

NuGet Version and Downloads count

RabbitMQ.Fakes.DotNetStandard is a .NET Standard 2.0 library (forked from the RabbitMQ.Fakes library) that contains fake implementations of the interfaces defined in the RabbitMQ.Client library.

The implementation is entirely in-memory, which eliminates the dependency on a live RabbitMQ server for unit testing.

NOTE: This library is inteded to be used for testing purposes, only (a la Microsoft.EntityFrameworkCore.InMemory).

Differences between RabbitMQ.Fakes and RabbitMQ.Fakes.DotNetStandard

RabbitMQ.Fakes is a .NET Framework 4.5 library, which is only compatible with .NET Framework.

RabbitMQ.Fakes.DotNetStandard is a .NET Standard 2.0 library, which is compatible with both .NET Framework and .NET Core.

RabbitMQ.Client versions

RabbitMQ.Fakes.DotNetStandard has a dependency on the RabbitMQ.Client library.

This may cause conflicts if you are referencing RabbitMQ.Fakes.DotNetStandard and RabbitMQ.Client (e.g. in a test project) with different versions of RabbitMQ.Client.

Below is a table of the version mappings between RabbitMQ.Fakes.DotNetStandard and RabbitMQ.Client.

RabbitMQ.Fakes.DotNetStandard Version RabbitMQ.Client Version
1.0.1 - 1.0.4 5.1.0
2.0.0+ 6.2.1

Requirements

Projects

  • RabbitMQ.Fakes.DotNetStandard: Implementation of the fakes using .NET Standard 2.0.
  • RabbitMQ.Fakes.DotNetCoreTests: Unit tests around the fake implementation using .NET Core 3.1.

Fakes

  • RabbitServer: In memory representation of a RabbitMQ server. This is where the Exchanges / Queues / Bindings / Messages are held.
  • FakeConnectionFactory: Fake implementation of the RabbitMQ IConnectionFactory. Returns a FakeConnection when the CreateConnection() method is called.
  • FakeConnection: Fake implementation of the RabbitMQ IConnection. Returns a FakeModel when the CreateModel() method is called.
  • FakeModel: Fake implementation of the RabbitMQ IModel. Interacts with the RabbitServer instance passed into the FakeConnectionFactory.

Sample Usage

See the UseCases in the RabbitMQ.Fakes.DotNetCoreTests project for sample usage.