HttpContext is read-only, but it is actually derived from the ControllerContext, which you can set.
controller.ControllerContext = new ControllerContext( context.Object, new RouteData(), controller );
More Related Contents:
- How to mock Controller.User using moq
- Mocking Extension Methods with Moq
- Mock HttpContext.Current in Test Init Method
- 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
- Why does the property I want to mock need to be virtual?
- Moq: unit testing a method relying on HttpContext
- Mocking generic methods in Moq without specifying T
- Correct way to use HttpContext.Current.User with async await
- Mocking using Moq in c#
- How do I create a custom membership provider for ASP.NET MVC 2?
- How to configure the web.config to allow requests of any length
- What is an MvcHtmlString and when should I use it?
- How to override an existing extension method
- MVCBuildViews not working correctly
- ASP.NET Web API : Correct way to return a 401/unauthorised response
- Using Moq to mock an asynchronous method for a unit test
- How to unit test with ILogger in ASP.NET Core
- MVC 5 BeginCollectionItem with Partial CRUD
- How to manually validate a model with attributes?
- How to retain spaces in DropDownList – ASP.net MVC Razor views
- Model binding with nested child models and PartialViews in ASP.NET MVC
- {version} wildcard in MVC4 Bundle
- Razor/CSHTML – Any Benefit over what we have? [closed]
- Could not load file or assembly System, Version=2.0.5.0 in .NET 4 MVC 4 application
- Opposite of [compare(” “)] data annotation in .net?
- MVC MapPageRoute and ActionLink