0

I have a .NET 6 app and I am creating integration tests for this system. I use FakeItEasy and I have a problem with mocking a service which is not used directly in my test. The process looks like this:

  1. Prepare data for the test
  2. Send first command - I don't mock anything here
  3. The first command is handled by a specific handler in the system
  4. Do a few things there; most importantly - one of the filters sends a second (different than the first one) command
  5. The second command is handled by a specific handler - this is where the service is which I want to mock

I don't have any idea for this example. I cannot pass a mocking version of the service in the body of the test because I don't use it directly in the test.

Could you give me some idea how can I do this?

  • FakeItEasy doesn't include any special powers for delivering your Fakes to your system under test. Normally you'd use whatever method you would to deliver any dependency: constructor injection (which you've said isn't an option here), some sort of official Dependency Injection library, a well-known registry, or something. Look at how you're delivering your dependency today and how it can be adapted to swap in an object defined at test time. – Blair Conrad Aug 18 '23 at 10:31

0 Answers0