Top "Moq" questions

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

Verify a method call using Moq

I am fairly new to unit testing in C# and learning to use Moq. Below is the class that I …

c# testing methods moq
Why am I getting an Exception with the message "Invalid setup on a non-virtual (overridable in VB) member..."?

I have a unit test where I have to mock a non-virtual method that returns a bool type public class …

c# unit-testing moq
How can I tell Moq to return a Task?

I've got an interface which declares Task DoSomethingAsync(); I'm using MoqFramework for my tests: [TestMethod()] public async Task MyAsyncTest() { Mock&…

c# unit-testing task-parallel-library moq
Assigning out/ref parameters in Moq

Is it possible to assign an out/ref parameter using Moq (3.0+)? I've looked at using Callback(), but Action<> …

c# parameters moq ref out
Moq, SetupGet, Mocking a property

I'm trying to mock a class, called UserInputEntity, which contains a property called ColumnNames: (it does contain other properties, I've …

c# c#-4.0 properties moq
Returning value that was passed into a method

I have a method on an interface: string DoSomething(string whatever); I want to mock this with MOQ, so that …

c# mocking moq
Verifying a specific parameter with Moq

public void SubmitMessagesToQueue_OneMessage_SubmitSuccessfully() { var messageServiceClientMock = new Mock<IMessageServiceClient>(); var queueableMessage = CreateSingleQueueableMessage(); var message = queueableMessage[0]; var xml = …

c# unit-testing nunit moq
Mocking Extension Methods with Moq

I have a preexisting Interface... public interface ISomeInterface { void SomeMethod(); } and I've extended this intreface using a mixin... public static …

c# unit-testing mocking extension-methods moq
Mocking HttpClient in unit tests

I have some issues trying to wrap my code to be used in unit tests. The issues is this. I …

c# unit-testing moq
How to mock static methods in c# using MOQ framework?

I have been doing unit testing recently and I've successfully mocked various scenarios using MOQ framework and MS Test. I …

c# unit-testing mocking moq