17
How would I mock the caching object on the ControllerContext object for my unit tests? I have tried creating a wrapper class like the following (since the cache object is a sealed class) with no luck.
var mockControllerContext = new Mock<ControllerContext>();
var mockhttpContext = new Mock<HttpContextBase>();
mockhttpContext.SetupGet(o => o.Cache).Returns(
new CacheWrapper(mockControllerContext.Object.HttpContext.Cache));
mockControllerContext.SetupGet(
o => o.HttpContext).Returns(mockhttpContext.Object);
this.tennisMatchupController.ControllerContext = mockControllerContext.Object;