@@ -246,17 +246,21 @@ public async Task FileFromDisk_ReturnsFileWithFileName_IfRangeHeaderInvalid_Rang
246
246
Assert . Equal ( "This is a sample text file" , body ) ;
247
247
}
248
248
249
+ // Use int for HttpStatusCode data because xUnit cannot serialize a GAC'd enum when running on .NET Framework.
249
250
[ Theory ]
250
- [ InlineData ( "" , HttpStatusCode . OK , 26 ) ]
251
- [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent , 7 ) ]
252
- [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent , 9 ) ]
253
- [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent , 26 ) ]
254
- [ InlineData ( "0-6" , HttpStatusCode . OK , 26 ) ]
255
- [ InlineData ( "bytes = " , HttpStatusCode . OK , 26 ) ]
256
- [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK , 26 ) ]
257
- [ InlineData ( "bytes = 35-36" , HttpStatusCode . RequestedRangeNotSatisfiable , 26 ) ]
258
- [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable , 26 ) ]
259
- public async Task FileFromDisk_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest_WithLastModifiedAndEtag ( string rangeString , HttpStatusCode httpStatusCode , int expectedContentLength )
251
+ [ InlineData ( "" , ( int ) HttpStatusCode . OK , 26 ) ]
252
+ [ InlineData ( "bytes = 0-6" , ( int ) HttpStatusCode . PartialContent , 7 ) ]
253
+ [ InlineData ( "bytes = 17-25" , ( int ) HttpStatusCode . PartialContent , 9 ) ]
254
+ [ InlineData ( "bytes = 0-50" , ( int ) HttpStatusCode . PartialContent , 26 ) ]
255
+ [ InlineData ( "0-6" , ( int ) HttpStatusCode . OK , 26 ) ]
256
+ [ InlineData ( "bytes = " , ( int ) HttpStatusCode . OK , 26 ) ]
257
+ [ InlineData ( "bytes = 1-4, 5-11" , ( int ) HttpStatusCode . OK , 26 ) ]
258
+ [ InlineData ( "bytes = 35-36" , ( int ) HttpStatusCode . RequestedRangeNotSatisfiable , 26 ) ]
259
+ [ InlineData ( "bytes = -0" , ( int ) HttpStatusCode . RequestedRangeNotSatisfiable , 26 ) ]
260
+ public async Task FileFromDisk_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest_WithLastModifiedAndEtag (
261
+ string rangeString ,
262
+ int httpStatusCode ,
263
+ int expectedContentLength )
260
264
{
261
265
// Arrange
262
266
var httpRequestMessage = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/DownloadFiles/DownloadFromDiskWithFileName_WithLastModifiedAndEtag" ) ;
@@ -267,7 +271,7 @@ public async Task FileFromDisk_ReturnsFileWithFileName_DoesNotServeBody_ForHeadR
267
271
var response = await Client . SendAsync ( httpRequestMessage ) ;
268
272
269
273
// Assert
270
- Assert . Equal ( httpStatusCode , response . StatusCode ) ;
274
+ Assert . Equal ( httpStatusCode , ( int ) response . StatusCode ) ;
271
275
272
276
Assert . NotNull ( response . Content . Headers . ContentType ) ;
273
277
Assert . Equal ( "text/plain" , response . Content . Headers . ContentType . ToString ( ) ) ;
@@ -442,17 +446,21 @@ public async Task FileFromStream_ReturnsFileWithFileName_IfRangeHeaderInvalid_Ra
442
446
Assert . Equal ( "This is sample text from a stream" , body ) ;
443
447
}
444
448
449
+ // Use int for HttpStatusCode data because xUnit cannot serialize a GAC'd enum when running on .NET Framework.
445
450
[ Theory ]
446
- [ InlineData ( "" , HttpStatusCode . OK , 33 ) ]
447
- [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent , 7 ) ]
448
- [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent , 9 ) ]
449
- [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent , 33 ) ]
450
- [ InlineData ( "0-6" , HttpStatusCode . OK , 33 ) ]
451
- [ InlineData ( "bytes = " , HttpStatusCode . OK , 33 ) ]
452
- [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK , 33 ) ]
453
- [ InlineData ( "bytes = 35-36" , HttpStatusCode . RequestedRangeNotSatisfiable , 33 ) ]
454
- [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable , 33 ) ]
455
- public async Task FileFromStream_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode , int expectedContentLength )
451
+ [ InlineData ( "" , ( int ) HttpStatusCode . OK , 33 ) ]
452
+ [ InlineData ( "bytes = 0-6" , ( int ) HttpStatusCode . PartialContent , 7 ) ]
453
+ [ InlineData ( "bytes = 17-25" , ( int ) HttpStatusCode . PartialContent , 9 ) ]
454
+ [ InlineData ( "bytes = 0-50" , ( int ) HttpStatusCode . PartialContent , 33 ) ]
455
+ [ InlineData ( "0-6" , ( int ) HttpStatusCode . OK , 33 ) ]
456
+ [ InlineData ( "bytes = " , ( int ) HttpStatusCode . OK , 33 ) ]
457
+ [ InlineData ( "bytes = 1-4, 5-11" , ( int ) HttpStatusCode . OK , 33 ) ]
458
+ [ InlineData ( "bytes = 35-36" , ( int ) HttpStatusCode . RequestedRangeNotSatisfiable , 33 ) ]
459
+ [ InlineData ( "bytes = -0" , ( int ) HttpStatusCode . RequestedRangeNotSatisfiable , 33 ) ]
460
+ public async Task FileFromStream_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest (
461
+ string rangeString ,
462
+ int httpStatusCode ,
463
+ int expectedContentLength )
456
464
{
457
465
// Arrange
458
466
var httpRequestMessage = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/DownloadFiles/DownloadFromStreamWithFileName_WithEtag" ) ;
@@ -463,7 +471,7 @@ public async Task FileFromStream_ReturnsFileWithFileName_DoesNotServeBody_ForHea
463
471
var response = await Client . SendAsync ( httpRequestMessage ) ;
464
472
465
473
// Assert
466
- Assert . Equal ( httpStatusCode , response . StatusCode ) ;
474
+ Assert . Equal ( httpStatusCode , ( int ) response . StatusCode ) ;
467
475
468
476
Assert . NotNull ( response . Content . Headers . ContentType ) ;
469
477
Assert . Equal ( "text/plain" , response . Content . Headers . ContentType . ToString ( ) ) ;
@@ -616,7 +624,7 @@ public async Task FileFromBinaryData_ReturnsFileWithFileName_IfRangeHeaderValid(
616
624
var response = await Client . SendAsync ( httpRequestMessage ) ;
617
625
var body = await response . Content . ReadAsStringAsync ( ) ;
618
626
619
- // Assert
627
+ // Assert
620
628
Assert . NotNull ( response . Content . Headers . ContentType ) ;
621
629
Assert . Equal ( "text/plain" , response . Content . Headers . ContentType . ToString ( ) ) ;
622
630
Assert . NotNull ( body ) ;
@@ -643,17 +651,21 @@ public async Task FileFromBinaryData_ReturnsFileWithFileName_IfRangeHeaderInvali
643
651
Assert . Equal ( "This is a sample text from a binary array" , body ) ;
644
652
}
645
653
654
+ // Use int for HttpStatusCode data because xUnit cannot serialize a GAC'd enum when running on .NET Framework.
646
655
[ Theory ]
647
- [ InlineData ( "" , HttpStatusCode . OK , 41 ) ]
648
- [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent , 7 ) ]
649
- [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent , 9 ) ]
650
- [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent , 41 ) ]
651
- [ InlineData ( "0-6" , HttpStatusCode . OK , 41 ) ]
652
- [ InlineData ( "bytes = " , HttpStatusCode . OK , 41 ) ]
653
- [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK , 41 ) ]
654
- [ InlineData ( "bytes = 45-46" , HttpStatusCode . RequestedRangeNotSatisfiable , 41 ) ]
655
- [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable , 41 ) ]
656
- public async Task FileFromBinaryData_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode , int expectedContentLength )
656
+ [ InlineData ( "" , ( int ) HttpStatusCode . OK , 41 ) ]
657
+ [ InlineData ( "bytes = 0-6" , ( int ) HttpStatusCode . PartialContent , 7 ) ]
658
+ [ InlineData ( "bytes = 17-25" , ( int ) HttpStatusCode . PartialContent , 9 ) ]
659
+ [ InlineData ( "bytes = 0-50" , ( int ) HttpStatusCode . PartialContent , 41 ) ]
660
+ [ InlineData ( "0-6" , ( int ) HttpStatusCode . OK , 41 ) ]
661
+ [ InlineData ( "bytes = " , ( int ) HttpStatusCode . OK , 41 ) ]
662
+ [ InlineData ( "bytes = 1-4, 5-11" , ( int ) HttpStatusCode . OK , 41 ) ]
663
+ [ InlineData ( "bytes = 45-46" , ( int ) HttpStatusCode . RequestedRangeNotSatisfiable , 41 ) ]
664
+ [ InlineData ( "bytes = -0" , ( int ) HttpStatusCode . RequestedRangeNotSatisfiable , 41 ) ]
665
+ public async Task FileFromBinaryData_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest (
666
+ string rangeString ,
667
+ int httpStatusCode ,
668
+ int expectedContentLength )
657
669
{
658
670
// Arrange
659
671
var httpRequestMessage = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/DownloadFiles/DownloadFromBinaryDataWithFileName_WithEtag" ) ;
@@ -664,7 +676,7 @@ public async Task FileFromBinaryData_ReturnsFileWithFileName_DoesNotServeBody_Fo
664
676
var response = await Client . SendAsync ( httpRequestMessage ) ;
665
677
666
678
// Assert
667
- Assert . Equal ( httpStatusCode , response . StatusCode ) ;
679
+ Assert . Equal ( httpStatusCode , ( int ) response . StatusCode ) ;
668
680
669
681
Assert . NotNull ( response . Content . Headers . ContentType ) ;
670
682
Assert . Equal ( "text/plain" , response . Content . Headers . ContentType . ToString ( ) ) ;
@@ -842,17 +854,21 @@ public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_RangeRequest
842
854
Assert . Equal ( "attachment; filename=downloadName.txt; filename*=UTF-8''downloadName.txt" , contentDisposition ) ;
843
855
}
844
856
857
+ // Use int for HttpStatusCode data because xUnit cannot serialize a GAC'd enum when running on .NET Framework.
845
858
[ Theory ]
846
- [ InlineData ( "" , HttpStatusCode . OK , 38 ) ]
847
- [ InlineData ( "bytes = 0-6" , HttpStatusCode . PartialContent , 7 ) ]
848
- [ InlineData ( "bytes = 17-25" , HttpStatusCode . PartialContent , 9 ) ]
849
- [ InlineData ( "bytes = 0-50" , HttpStatusCode . PartialContent , 38 ) ]
850
- [ InlineData ( "0-6" , HttpStatusCode . OK , 38 ) ]
851
- [ InlineData ( "bytes = " , HttpStatusCode . OK , 38 ) ]
852
- [ InlineData ( "bytes = 1-4, 5-11" , HttpStatusCode . OK , 38 ) ]
853
- [ InlineData ( "bytes = 45-46" , HttpStatusCode . RequestedRangeNotSatisfiable , 38 ) ]
854
- [ InlineData ( "bytes = -0" , HttpStatusCode . RequestedRangeNotSatisfiable , 38 ) ]
855
- public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest ( string rangeString , HttpStatusCode httpStatusCode , int expectedContentLength )
859
+ [ InlineData ( "" , ( int ) HttpStatusCode . OK , 38 ) ]
860
+ [ InlineData ( "bytes = 0-6" , ( int ) HttpStatusCode . PartialContent , 7 ) ]
861
+ [ InlineData ( "bytes = 17-25" , ( int ) HttpStatusCode . PartialContent , 9 ) ]
862
+ [ InlineData ( "bytes = 0-50" , ( int ) HttpStatusCode . PartialContent , 38 ) ]
863
+ [ InlineData ( "0-6" , ( int ) HttpStatusCode . OK , 38 ) ]
864
+ [ InlineData ( "bytes = " , ( int ) HttpStatusCode . OK , 38 ) ]
865
+ [ InlineData ( "bytes = 1-4, 5-11" , ( int ) HttpStatusCode . OK , 38 ) ]
866
+ [ InlineData ( "bytes = 45-46" , ( int ) HttpStatusCode . RequestedRangeNotSatisfiable , 38 ) ]
867
+ [ InlineData ( "bytes = -0" , ( int ) HttpStatusCode . RequestedRangeNotSatisfiable , 38 ) ]
868
+ public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_DoesNotServeBody_ForHeadRequest (
869
+ string rangeString ,
870
+ int httpStatusCode ,
871
+ int expectedContentLength )
856
872
{
857
873
// Arrange
858
874
var httpRequestMessage = new HttpRequestMessage ( HttpMethod . Head , "http://localhost/EmbeddedFiles/DownloadFileWithFileName" ) ;
@@ -863,7 +879,7 @@ public async Task FileFromEmbeddedResources_ReturnsFileWithFileName_DoesNotServe
863
879
var response = await Client . SendAsync ( httpRequestMessage ) ;
864
880
865
881
// Assert
866
- Assert . Equal ( httpStatusCode , response . StatusCode ) ;
882
+ Assert . Equal ( httpStatusCode , ( int ) response . StatusCode ) ;
867
883
868
884
Assert . NotNull ( response . Content . Headers . ContentType ) ;
869
885
Assert . Equal ( "text/plain" , response . Content . Headers . ContentType . ToString ( ) ) ;
0 commit comments