I have used a Wrapper to get around this problem. Create a wrapper object and pass your mocked method.
See Mocking Static Methods for Unit Testing by Paul Irwin, it has nice examples.
More Related Contents:
- How do I use Moq to mock an extension method?
- Mocking Static Methods
- How to mock static methods in c# using MOQ framework?
- Is it possible to mock out a .NET HttpWebResponse?
- Using Moq to determine if a method is called
- Moq: unit testing a method relying on HttpContext
- How to mock Controller.User using moq
- Mocking using Moq in c#
- Using IoC for Unit Testing
- How do I mock the HttpContext in ASP.NET MVC using Moq?
- Mocking HttpClient in unit tests
- How do you mock out the file system in C# for unit testing?
- Mock static property with moq
- How to mock the new HttpClientFactory in .NET Core 2.1 using Moq
- How can I tell Moq to return a Task?
- Why am I getting an Exception with the message “Invalid setup on a non-virtual (overridable in VB) member…”?
- Using Moq to mock an asynchronous method for a unit test
- Moq + Unit Testing – System.Reflection.TargetParameterCountException: Parameter count mismatch
- How to unit test with ILogger in ASP.NET Core
- How to mock ConfigurationManager.AppSettings with moq
- Mocking EF DbContext with Moq
- Why does the property I want to mock need to be virtual?
- How to test method call order with Moq
- Moq – Non-overridable members may not be used in setup / verification expressions
- How do I mock User.Identity.GetUserId()?
- How do I Moq a method that has an optional argument in its signature without explicitly specifying it or using an overload?
- Mocking generic methods in Moq without specifying T
- Unit testing with EF Core and in memory database
- Using Moq to override virtual methods in the same class
- How to write this EF Mock setup code as a reusable Generic Boilerplate?