Mocking with FakeItEasy

Mocking with FakeItEasy

On September 18, 2019, I gave an internal talk to the Dootrix team about the C# mocking library, FakeItEasy. The talk was aimed at helping the team to understand how to use FakeItEasy to create mock objects for testing .NET applications.

During the talk, I provided an overview of the basic concepts of mocking and how to use FakeItEasy to create mocks. We discussed how to define and use mock objects to simulate parts of our systems, and how to verify that the expected interactions occurred. Additionally, I highlighted the benefits of using mock objects in unit testing, such as isolating code under test and making tests more reliable.

To make the presentation more engaging and practical, I provided examples of how to use FakeItEasy to test different scenarios. I demonstrated how to create mocks for interfaces and classes, how to set up expectations and behaviours for mock objects, and how to verify that the expected interactions occurred. I also showed how to use the mocking library in different contexts, such as when testing databases or web services.

The presentation was made available at https://docs.google.com/presentation/d/1g9ZmopOqWPAijC792OXlU5lXD3cbMIjCYa54wWJl1NI/edit?usp=sharing, so that the team could refer to it later on. The talk was interactive, and questions were encouraged. The team asked questions about how to use the library in specific contexts, how to manage the complexity of tests that require multiple mock objects, and how to ensure that the tests remain maintainable over time.

After the presentation, the team members were able to implement the knowledge gained from the talk to improve their testing practices. They were able to write more effective tests that helped to expose bugs and errors in the codebase. The presentation also helped them to understand the importance of writing tests that are maintainable and less prone to breaking.

Overall, the talk was well received and sparked some interesting discussions about testing practices within the team. By the end of the talk, everyone had a better understanding of how to use FakeItEasy to create mocks for their .NET applications. This was evident in the feedback that I received from the team members who found the presentation to be informative and helpful.

In conclusion, the talk was a success as it helped the team to improve their testing practices, and also showed them how to leverage the FakeItEasy mocking library to write better tests for their .NET applications. The team felt more confident in their testing abilities and were able to write more efficient and effective tests.