Scenario:
I have a base controller which disables caching within the OnActionExecuting override.
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
    filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
    filterContext.HttpContext.开发者_StackOverflow中文版Response.Cache.SetValidUntilExpires(false);
    filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
    filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); //IE
    filterContext.HttpContext.Response.Cache.SetNoStore(); //FireFox 
}
How can I create a Unit Test to test this behavior?
Trying to do the same. The best I have so far is this...
    [TestCase]
    public void ResponseNotFromCache()
    {
            System.Net.WebRequest rq = System.Net.WebRequest.Create("testmethod");
            System.Net.HttpWebResponse rs = rq.GetResponse() as System.Net.HttpWebResponse;
            Assert.IsFalse(rs.IsFromCache);
    }
There must be a better way!
Update: How can I test an event of a MVC controller
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论