Add more functional tests of cache profiles

This commit is contained in:
Doug Bunting 2015-04-07 21:24:14 -07:00
parent 58a5ad2279
commit 8965ac96c0
3 changed files with 29 additions and 0 deletions

View File

@ -244,6 +244,23 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
Assert.Equal("public, max-age=10", data);
}
[Fact]
public async Task ResponseCache_FallbackToFilter_IfNoAttribute()
{
// Arrange
var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient();
// Act
var response = await client.GetAsync("http://localhost/CacheProfiles/FallbackToFilter");
// Assert
var data = Assert.Single(response.Headers.GetValues("Cache-control"));
Assert.Equal("no-store", data);
data = Assert.Single(response.Headers.GetValues("Vary"));
Assert.Equal("TestDefault", data);
}
[Fact]
public async Task ResponseCacheAttribute_OnAction_OverridesTheValuesOnClass()
{

View File

@ -41,5 +41,11 @@ namespace ResponseCacheWebSite.Controllers
{
return "Hello World!";
}
[HttpGet("/CacheProfiles/FallbackToFilter")]
public string FallbackToFilter()
{
return "Hello World!";
}
}
}

View File

@ -36,6 +36,12 @@ namespace ResponseCacheWebSite
Duration = 0,
Location = ResponseCacheLocation.None
});
options.Filters.Add(new ResponseCacheFilter(new CacheProfile
{
NoStore = true,
VaryByHeader = "TestDefault",
}));
});
}