public void Properties() { HttpResponse response = new HttpResponse(Console.Out); HttpCacheVaryByHeaders hdrs = response.Cache.VaryByHeaders; /* first test all the getters/setters for the builtin fields */ hdrs.AcceptTypes = true; hdrs.UserAgent = true; hdrs.UserCharSet = true; hdrs.UserLanguage = true; hdrs["custom-field"] = true; Assert.IsTrue(hdrs.AcceptTypes, "hdrs.AcceptTypes == true"); Assert.IsTrue(hdrs.UserAgent, "hdrs.UserAgent == true"); Assert.IsTrue(hdrs.UserCharSet, "hdrs.UserCharSet == true"); Assert.IsTrue(hdrs.UserLanguage, "hdrs.UserLanguage == true"); Assert.IsTrue(hdrs["custom-field"], "hdrs['custom-field'] == true"); /* test case sensitivity */ Assert.IsTrue(hdrs["Custom-Field"], "hdrs['Custom-Field'] == true"); hdrs.VaryByUnspecifiedParameters(); /* now verify that they're all false */ Assert.IsFalse(hdrs.AcceptTypes, "hdrs.AcceptTypes == false"); Assert.IsFalse(hdrs.UserAgent, "hdrs.UserAgent == false"); Assert.IsFalse(hdrs.UserCharSet, "hdrs.UserCharSet == false"); Assert.IsFalse(hdrs.UserLanguage, "hdrs.UserLanguage == false"); Assert.IsFalse(hdrs["custom-field"], "hdrs['custom-field'] == false"); }
public void Deny_Unrestricted() { HttpCacheVaryByHeaders cache = response.Cache.VaryByHeaders; Assert.IsFalse(cache.AcceptTypes, "AcceptTypes"); cache.AcceptTypes = true; Assert.IsFalse(cache.UserAgent, "UserAgent"); cache.UserAgent = true; Assert.IsFalse(cache.UserCharSet, "UserCharSet"); cache.UserCharSet = true; Assert.IsFalse(cache.UserLanguage, "UserLanguage"); cache.UserLanguage = true; Assert.IsFalse(cache["mono"], "this[string]"); cache["mono"] = true; cache.VaryByUnspecifiedParameters(); }