Top "Moq" questions

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

Mocking a method to throw an exception (moq), but otherwise act like the mocked object?

I have a Transfer class, simplified it looks like this: public class Transfer { public virtual IFileConnection source { get; set; } public …

c# unit-testing mocking moq
Mocking objects with Moq when constructor has parameters

I have an object I'm trying to mock using moq. The object's constructor has required parameters: public class CustomerSyncEngine { public …

moq
Using Moq to mock an asynchronous method for a unit test

I am testing a method for a service that makes a Web API call. Using a normal HttpClient works fine …

c# unit-testing asynchronous moq
Mocking EF DbContext with Moq

I'm trying to create a unit test for my service with a mocked DbContext. I created an interface IDbContext with …

c# unit-testing entity-framework-5 moq dbcontext
Different return values the first and second time with Moq

I have a test like this: [TestCase("~/page/myaction")] public void Page_With_Custom_Action(string path) { // Arrange var pathData = …

c# unit-testing nunit moq
Using Moq to determine if a method is called

It is my understanding that I can test that a method call will occur if I call a higher level …

c# .net unit-testing mocking moq
Moq: How to get to a parameter passed to a method of a mocked service

Imagine this class public class Foo { private Handler _h; public Foo(Handler h) { _h = h; } public void Bar(int i) { _…

c# moq
How to mock the Request on Controller in ASP.Net MVC?

I have a controller in C# using the ASP.Net MVC framework public class HomeController:Controller{ public ActionResult Index() { if (…

asp.net-mvc unit-testing mocking rhino-mocks moq
Can you help me understand Moq Callback?

Using Moq and looked at Callback but I have not been able to find a simple example to understand how …

.net moq
Multiple Moq It.Is<string>() Matching Arguments

With Moq, is it valid to have more than one Matching Argument? It.Is<string>() In this example …

c# unit-testing mocking moq