@@ -172,13 +172,13 @@ private async Task RunApiGatewayTest<T>(HttpContextTestCase testCase, string api
172172
173173 CompareApiGatewayRequests ( expectedApiGatewayRequest , actualApiGatewayRequest ) ;
174174
175- testCase . Assertions ( actualApiGatewayRequest , emulatorMode ) ;
175+ testCase . Assertions ( actualApiGatewayRequest ! , emulatorMode ) ;
176176
177177 await Task . Delay ( 1000 ) ; // Small delay between requests
178178 }
179179
180180
181- private void CompareApiGatewayRequests < T > ( T expected , T actual ) where T : class
181+ private void CompareApiGatewayRequests < T > ( T expected , T actual ) where T : class ?
182182 {
183183 if ( expected is APIGatewayProxyRequest v1Expected && actual is APIGatewayProxyRequest v1Actual )
184184 {
@@ -261,23 +261,25 @@ private void CompareMultiValueHeaders(IDictionary<string, IList<string>> expecte
261261 }
262262 }
263263
264- private IDictionary < TKey , TValue > FilterHeaders < TKey , TValue > ( IDictionary < TKey , TValue > headers )
264+ private IDictionary < TKey , TValue > FilterHeaders < TKey , TValue > ( IDictionary < TKey , TValue > headers ) where TKey : notnull
265265 {
266266 return headers . Where ( kvp =>
267- ! ( kvp . Key . ToString ( ) . StartsWith ( "x-forwarded-" , StringComparison . OrdinalIgnoreCase ) || // ignore these for now
268- kvp . Key . ToString ( ) . StartsWith ( "cloudfront-" , StringComparison . OrdinalIgnoreCase ) || // ignore these for now
269- kvp . Key . ToString ( ) . StartsWith ( "via-" , StringComparison . OrdinalIgnoreCase ) || // ignore these for now
270- kvp . Key . ToString ( ) . Equals ( "x-amzn-trace-id" , StringComparison . OrdinalIgnoreCase ) || // this is dynamic so ignoring for now
271- kvp . Key . ToString ( ) . Equals ( "cookie" , StringComparison . OrdinalIgnoreCase ) || // TODO may have to have api gateway v2 not set this in headers
272- kvp . Key . ToString ( ) . Equals ( "host" , StringComparison . OrdinalIgnoreCase ) ) ) // TODO we may want to set this
267+ ! ( kvp . Key . ToString ( ) ! . StartsWith ( "x-forwarded-" , StringComparison . OrdinalIgnoreCase ) || // ignore these for now
268+ kvp . Key . ToString ( ) ! . StartsWith ( "cloudfront-" , StringComparison . OrdinalIgnoreCase ) || // ignore these for now
269+ kvp . Key . ToString ( ) ! . StartsWith ( "via-" , StringComparison . OrdinalIgnoreCase ) || // ignore these for now
270+ kvp . Key . ToString ( ) ! . Equals ( "x-amzn-trace-id" , StringComparison . OrdinalIgnoreCase ) || // this is dynamic so ignoring for now
271+ kvp . Key . ToString ( ) ! . Equals ( "cookie" , StringComparison . OrdinalIgnoreCase ) || // TODO may have to have api gateway v2 not set this in headers
272+ kvp . Key . ToString ( ) ! . Equals ( "host" , StringComparison . OrdinalIgnoreCase ) ) ) // TODO we may want to set this
273273 . ToDictionary ( kvp => kvp . Key , kvp => kvp . Value ) ;
274274 }
275275
276276
277- private void CompareDictionaries < TKey , TValue > ( IDictionary < TKey , TValue > expected , IDictionary < TKey , TValue > actual )
277+ private void CompareDictionaries < TKey , TValue > ( IDictionary < TKey , TValue > ? expected , IDictionary < TKey , TValue > ? actual )
278278 {
279279 if ( expected == null && actual == null ) return ;
280- Assert . Equal ( expected . Count , actual . Count ) ;
280+ if ( expected == null && actual != null ) Assert . Fail ( ) ;
281+ if ( expected != null && actual == null ) Assert . Fail ( ) ;
282+ Assert . Equal ( expected ! . Count , actual ! . Count ) ;
281283
282284 foreach ( var kvp in expected )
283285 {
@@ -291,7 +293,7 @@ private void CompareStringArrays(string[] expected, string[] actual)
291293 Assert . Equal ( expected ? . Length , actual ? . Length ) ;
292294 if ( expected != null )
293295 {
294- Assert . Equal ( expected . OrderBy ( x => x ) , actual . OrderBy ( x => x ) ) ;
296+ Assert . Equal ( expected . OrderBy ( x => x ) , actual ? . OrderBy ( x => x ) ) ;
295297 }
296298 }
297299
0 commit comments