Fixing the build break.
This commit is contained in:
parent
b08a2154c1
commit
645b82d194
|
|
@ -228,30 +228,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||||
Assert.Equal(expected2, response2.Trim());
|
Assert.Equal(expected2, response2.Trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task CacheTagHelper_Activated_BasedOnEnabledParameter()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
|
|
||||||
var client = server.CreateClient();
|
|
||||||
client.BaseAddress = new Uri("http://localhost");
|
|
||||||
|
|
||||||
// Act
|
|
||||||
// This is cached for 1s.
|
|
||||||
var response1 = await client.GetStringAsync("/catalog/31");
|
|
||||||
var response2 = await client.GetStringAsync("/catalog/32");
|
|
||||||
|
|
||||||
// This request is made before the cache expires with enabled set to false.
|
|
||||||
client.DefaultRequestHeaders.Remove("IsCacheEnabled");
|
|
||||||
client.DefaultRequestHeaders.Add("IsCacheEnabled", "false");
|
|
||||||
var response3 = await client.GetStringAsync("/catalog/156");
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.Equal("Cached content for 31", response1.Trim());
|
|
||||||
Assert.Equal("Cached content for 31", response2.Trim());
|
|
||||||
Assert.Equal("Cached content for 156", response3.Trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task CacheTagHelper_UsesVaryByCookie_ToVaryContent()
|
public async Task CacheTagHelper_UsesVaryByCookie_ToVaryContent()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,8 @@ namespace MvcTagHelpersWebSite.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/catalog/{id:int}")]
|
[HttpGet("/catalog/{id:int}")]
|
||||||
public ViewResult Details(int id, [FromHeader] string isCacheEnabled)
|
public ViewResult Details(int id)
|
||||||
{
|
{
|
||||||
bool cacheEnabledHeader = true;
|
|
||||||
if (!string.IsNullOrEmpty(isCacheEnabled))
|
|
||||||
{
|
|
||||||
bool.TryParse(isCacheEnabled, out cacheEnabledHeader);
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewBag.IsCacheEnabled = cacheEnabledHeader;
|
|
||||||
ViewData["ProductId"] = id;
|
ViewData["ProductId"] = id;
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
@using Microsoft.Framework.Caching.Memory
|
@using Microsoft.Framework.Caching.Memory
|
||||||
<cache expires-after="TimeSpan.FromSeconds(1)" priority="CachePreservationPriority.Low" enabled="ViewBag.IsCacheEnabled">
|
<cache expires-after="TimeSpan.FromSeconds(1)" priority="CachePreservationPriority.Low">
|
||||||
Cached content for @ViewBag.ProductId
|
Cached content for @ViewBag.ProductId
|
||||||
</cache>
|
</cache>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue