public void Should_apply_profile_setting() { var att = new OutputCacheAttribute(); Global.CacheProfileProvider.ApplyProfileSetting(att, "Profile1-Two-Seconds"); Assert.AreEqual(2, att.Duration); Assert.AreEqual(5, att.StaleWhileRevalidate); Assert.AreEqual(true, att.AutoRefresh); Assert.AreEqual("packageId", att.VaryByParam); Assert.AreEqual("*", att.VaryByCustom); Assert.AreEqual("anything-about-{userId}", att.RevalidateKeyFormat); var att2 = new Flatwhite.WebApi.OutputCacheAttribute { MaxAge = 3, StaleWhileRevalidate = 4 }; Global.CacheProfileProvider.ApplyProfileSetting(att2, "Web-Profile2-Three-Seconds"); Assert.AreEqual(3, att2.MaxAge); Assert.AreEqual(6, att2.StaleWhileRevalidate); Assert.AreEqual(false, att2.AutoRefresh); Assert.AreEqual("*", att2.VaryByParam); Assert.AreEqual("UserAgent", att2.VaryByHeader); }
public void Should_combine_VaryByCustom_and_VaryByHeader() { // Arrange var att = new Flatwhite.WebApi.OutputCacheAttribute { VaryByCustom = "query.query1, query.query2", VaryByHeader = "UserAgent, CacheControl.Public" }; // Action Assert.AreEqual("query.query1, query.query2, headers.UserAgent, headers.CacheControl.Public", att.GetAllVaryCustomKey()); }
public void Should_set_profile_setting() { // Arrange var provider = Substitute.For<IOutputCacheProfileProvider>(); Global.CacheProfileProvider = provider; // Action var att = new Flatwhite.WebApi.OutputCacheAttribute { CacheProfile = "someProfile" }; // Assert provider.Received(1).ApplyProfileSetting(att, "someProfile"); Assert.AreEqual("someProfile", att.CacheProfile); }
public void Should_set_profile_setting() { // Arrange var provider = Substitute.For <IOutputCacheProfileProvider>(); Global.CacheProfileProvider = provider; // Action var att = new Flatwhite.WebApi.OutputCacheAttribute { CacheProfile = "someProfile" }; // Assert provider.Received(1).ApplyProfileSetting(att, "someProfile"); Assert.AreEqual("someProfile", att.CacheProfile); }