Top "Moq" questions

Moq is a strongly typed and minimalistic mocking framework for .NET.

How to mock a class that implements multiple interfaces

How to mock the following class: UserRepository : GenericRepository<User>, IUserRepository public class GenericRepository<TEntity> : IGenericRepository<…

c# mocking moq
Passing Moq mock-objects to constructor

I've been using RhinoMocks for a good while, but just started looking into Moq. I have this very basic problem, …

c# .net mocking moq
How to mock an SqlDataReader using Moq - Update

I'm new to moq and setting up mocks so i could do with a little help. How do I mock …

c# unit-testing mocking moq
Nunit testing with Mock. Instance of Interface

I have the following (simplified) code. public class Controller { private readonly IService _service; public Controller(IService service) { _service = service; } public …

c# mocking nunit moq simple-injector
Setup Method With Params Array

I am developing tests for an application. There's a method that has a params array as a parameter. I have …

c# nunit moq
Mock AutoMapper Mapper.Map call using Moq

Whats the best way to setup a mock expection for the Map function in AutoMapper. I extract the IMapper interface …

c# moq automapper
Moq - Need mocked function to return value passed in

I have a mock that i have setup like this. I need to return the same value that was passed …

mocking moq
Expression references a method that does not belong to the mocked object

I have an api service that calls another api service. When I set up the Mock objects, it failed with …

c# linq unit-testing expression moq
How to mock ModelState.IsValid using the Moq framework?

I'm checking ModelState.IsValid in my controller action method that creates an Employee like this: [HttpPost] public virtual ActionResult Create(…

c# asp.net-mvc unit-testing mocking moq
How to mock the new HttpClientFactory in .NET Core 2.1 using Moq

.NET Core 2.1 comes with this new factory called HttpClientFactory, but I can't figure out how to mock it to unit …

c# unit-testing moq asp.net-core-2.1 httpclientfactory