Sobes.tech
Junior — Middle

What library did you use for creating mock objects during testing?

sobes.tech AI

Answer from AI

To create mock objects in C# testing, the popular library used is Moq. It is one of the most popular and easy-to-use libraries for mocking, allowing the creation of fake implementations of interfaces and classes for unit tests.

Example of using Moq:

using Moq;

var mock = new Mock<IMyService>();
mock.Setup(service => service.GetData()).Returns("Test data");

var result = mock.Object.GetData();
Console.WriteLine(result); // Outputs "Test data"

Moq makes it easy to set method behaviors, verify calls, and configure various testing scenarios.

What library did you use for creating mock objects… - sobes.tech