@@ -17,6 +17,8 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests
1717{
1818 public class ResponseCachingContextTests
1919 {
20+ private static readonly char KeyDelimiter = '\x1e ' ;
21+
2022 [ Theory ]
2123 [ InlineData ( "GET" ) ]
2224 [ InlineData ( "HEAD" ) ]
@@ -171,7 +173,7 @@ public void CreateCacheKey_Includes_UppercaseMethodAndPath()
171173 httpContext . Request . QueryString = new QueryString ( "?query.Key=a&query.Value=b" ) ;
172174 var context = CreateTestContext ( httpContext ) ;
173175
174- Assert . Equal ( "HEAD; /PATH/SUBPATH" , context . CreateCacheKey ( ) ) ;
176+ Assert . Equal ( $ "HEAD{ KeyDelimiter } /PATH/SUBPATH", context . CreateCacheKey ( ) ) ;
175177 }
176178
177179 [ Fact ]
@@ -184,7 +186,7 @@ public void CreateCacheKey_Includes_ListedVaryByHeadersOnly()
184186 httpContext . Request . Headers [ "HeaderB" ] = "ValueB" ;
185187 var context = CreateTestContext ( httpContext ) ;
186188
187- Assert . Equal ( "GET;/; HeaderA=ValueA; HeaderC=null" , context . CreateCacheKey ( new CachedVaryBy ( )
189+ Assert . Equal ( $ "GET{ KeyDelimiter } / { KeyDelimiter } H { KeyDelimiter } HeaderA=ValueA{ KeyDelimiter } HeaderC=null", context . CreateCacheKey ( new CachedVaryBy ( )
188190 {
189191 Headers = new string [ ] { "HeaderA" , "HeaderC" }
190192 } ) ) ;
@@ -199,7 +201,7 @@ public void CreateCacheKey_Includes_ListedVaryByParamsOnly()
199201 httpContext . Request . QueryString = new QueryString ( "?ParamA=ValueA&ParamB=ValueB" ) ;
200202 var context = CreateTestContext ( httpContext ) ;
201203
202- Assert . Equal ( "GET;/; ParamA=ValueA; ParamC=null" , context . CreateCacheKey ( new CachedVaryBy ( )
204+ Assert . Equal ( $ "GET{ KeyDelimiter } / { KeyDelimiter } Q { KeyDelimiter } ParamA=ValueA{ KeyDelimiter } ParamC=null", context . CreateCacheKey ( new CachedVaryBy ( )
203205 {
204206 Params = new string [ ] { "ParamA" , "ParamC" }
205207 } ) ) ;
@@ -214,7 +216,7 @@ public void CreateCacheKey_Includes_VaryByParams_ParamNameCaseInsensitive_UseVar
214216 httpContext . Request . QueryString = new QueryString ( "?parama=ValueA¶mB=ValueB" ) ;
215217 var context = CreateTestContext ( httpContext ) ;
216218
217- Assert . Equal ( "GET;/; ParamA=ValueA; ParamC=null" , context . CreateCacheKey ( new CachedVaryBy ( )
219+ Assert . Equal ( $ "GET{ KeyDelimiter } / { KeyDelimiter } Q { KeyDelimiter } ParamA=ValueA{ KeyDelimiter } ParamC=null", context . CreateCacheKey ( new CachedVaryBy ( )
218220 {
219221 Params = new string [ ] { "ParamA" , "ParamC" }
220222 } ) ) ;
@@ -231,7 +233,7 @@ public void CreateCacheKey_Includes_AllQueryParamsGivenAsterisk()
231233
232234 // To support case insensitivity, all param keys are converted to lower case.
233235 // Explicit VaryBy uses the casing specified in the setting.
234- Assert . Equal ( "GET;/; parama=ValueA; paramb=ValueB" , context . CreateCacheKey ( new CachedVaryBy ( )
236+ Assert . Equal ( $ "GET{ KeyDelimiter } / { KeyDelimiter } Q { KeyDelimiter } parama=ValueA{ KeyDelimiter } paramb=ValueB", context . CreateCacheKey ( new CachedVaryBy ( )
235237 {
236238 Params = new string [ ] { "*" }
237239 } ) ) ;
@@ -248,7 +250,7 @@ public void CreateCacheKey_Includes_ListedVaryByHeadersAndParams()
248250 httpContext . Request . QueryString = new QueryString ( "?ParamA=ValueA&ParamB=ValueB" ) ;
249251 var context = CreateTestContext ( httpContext ) ;
250252
251- Assert . Equal ( "GET;/; HeaderA=ValueA; HeaderC=null; ParamA=ValueA; ParamC=null" , context . CreateCacheKey ( new CachedVaryBy ( )
253+ Assert . Equal ( $ "GET{ KeyDelimiter } / { KeyDelimiter } H { KeyDelimiter } HeaderA=ValueA{ KeyDelimiter } HeaderC=null{ KeyDelimiter } Q { KeyDelimiter } ParamA=ValueA{ KeyDelimiter } ParamC=null", context . CreateCacheKey ( new CachedVaryBy ( )
252254 {
253255 Headers = new string [ ] { "HeaderA" , "HeaderC" } ,
254256 Params = new string [ ] { "ParamA" , "ParamC" }
@@ -270,7 +272,7 @@ public void CreateCacheKey_OptionalCacheKey_AppendedToDefaultKey()
270272 httpContext . Request . Headers [ "HeaderB" ] = "ValueB" ;
271273 var responseCachingContext = CreateTestContext ( httpContext , new CustomizeKeySuffixProvider ( ) ) ;
272274
273- Assert . Equal ( "GET;/; HeaderA=ValueA; HeaderC=null; CustomizedKey" , responseCachingContext . CreateCacheKey ( new CachedVaryBy ( )
275+ Assert . Equal ( $ "GET{ KeyDelimiter } / { KeyDelimiter } H { KeyDelimiter } HeaderA=ValueA{ KeyDelimiter } HeaderC=null{ KeyDelimiter } C { KeyDelimiter } CustomizedKey", responseCachingContext . CreateCacheKey ( new CachedVaryBy ( )
274276 {
275277 Headers = new string [ ] { "HeaderA" , "HeaderC" }
276278 } ) ) ;
0 commit comments