Sponsor: Using RabbitMQ or Azure Service Bus in your .NET systems? Well, you could just use their SDKs and roll your own serialization, routing, outbox, retries, and telemetry. I mean, seriously, how hard could it be?

ICakeContext
Since we are creating an extension method on theICakeContext
, we need an implementation we can use to test. One solution to this is to create a fake.
Ultimately what you need to do is implement the aspects of the ICakeContext
you use within your extension method. In my example, the only thing I was using was the Log
property.
For reference, here was my extension method:
FakeCakeContext
I’m going to create aFakeCakeContext
for my tests that will implement ICakeContext
. All the properties I need to implement I will be using FakeItEasy to create fakes.
Test
Now that we have ourFakeCakeContext
, we can write a test that calls our extension method. In our test, I’m using FakeItEasy to validate that the Log.Write
was actually called on the FakeCakeContext
.