Top "Moq" questions

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

Invoking Func passed as a parameter to a mock using Moq and C#

I have a mocked method that looks like this: class NotMineClass { T Execute(Func operation) { // do something return operation(); } } In …

c# .net moq capture xunit
How to mock ActionExecutingContext with Moq?

I am trying to test the following filter: using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.Filters; namespace Hello { public …

asp.net-mvc unit-testing moq xunit
ASP.NET Core Integration Testing & Mocking using Moq

I have the following ASP.NET Core integration test using a custom WebApplicationFactory public class CustomWebApplicationFactory<TEntryPoint> : WebApplicationFactory&…

asp.net-core asp.net-core-mvc moq xunit asp.net-core-testhost
xUnit and Moq do not support async - await keywords

I am trying to discover how to apply the async and await keywords to my xUnit tests. I am using …

c# moq async-await xunit.net
How to Unit Test HtmlHelper with Moq?

Could somebody show me how you would go about creating a mock HTML Helper with Moq? This article has a …

asp.net-mvc unit-testing nunit moq html-helper
Invoking Actions from Moq

I've got a service with a method that takes two Actions, one for success and one for failure. Each Action …

callback action moq anonymous func
Mocking Controller.Url.Action(string, string, object, string) in ASP.NET MVC

I use NUnit and Moq libraries for unit testing. I need to mock overloaded Url.Action(string, string, object, string), …

asp.net-mvc unit-testing moq urlhelper
Testing ValidationAttribute that overrides IsValid

I'm having a bit of trouble getting my head around testing my custom validation attribute. As the method signature is …

c# asp.net-mvc unit-testing moq validationattribute
MOQ - LINQ Predicates in Setup Method

In my method, I have my repository doing this: bool isConditionMet = MyRepository.Any(x => x.Condition == true); I am …

c# .net unit-testing moq predicate
How to moq a NetworkStream in a unit test?

I'm using Moq & NUnit as a unit test framework. I've written a method that is given a NetworkStream object …

c# unit-testing mocking moq networkstream