Top "Moq" questions

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

Mocking Static Methods

Recently, I've begun to use Moq to unit test. I use Moq to mock out classes that I don't need …

c# unit-testing mocking moq
Moq: Invalid setup on a non-overridable member: x => x.GetByTitle("asdf")

Not sure how I can fix this, trying to do a unit test on the method "GetByTitle" Here are my …

c# nhibernate nunit resharper moq
How to verify that method was NOT called in Moq?

How do I verify that method was NOT called in Moq? Does it have something like AssertWasNotCalled? UPDATE: Starting from …

c# .net moq
How to unit test with ILogger in ASP.NET Core

This is my controller: public class BlogController : Controller { private IDAO<Blog> _blogDAO; private readonly ILogger<BlogController> _…

c# unit-testing asp.net-core moq ilogger
Mock an update method returning a void with Moq

In my test, I defined as data a List<IUser> with some record in. I'd like setup a …

c# .net mocking moq
How to mock ConfigurationManager.AppSettings with moq

I am stuck at this point of code that I do not know how to mock: ConfigurationManager.AppSettings["User"]; I …

c# unit-testing moq
MOQ - setting up a method based on argument values (multiple arguments)

I have an interface defined as interface IMath { AddNumbersBetween(int lowerVal, int upperVal); } I can setup a basic Moq for …

c# unit-testing moq
How do I mock the HttpContext in ASP.NET MVC using Moq?

[TestMethod] public void Home_Message_Display_Unknown_User_when_coockie_does_not_exist() { var context = new Mock<HttpContextBase>(); …

c# asp.net-mvc mocking moq httpcontext
Why does the property I want to mock need to be virtual?

I'm doing some unit testing, and mocking some properties using Moq. Now, this is a Controller test (ASP.NET MVC 3). …

c# asp.net-mvc unit-testing controller moq
How do I use Moq to mock an extension method?

I am writing a test that depends on the results of an extension method but I don't want a future …

c# mocking moq extension-methods