66using System . Text ;
77using System . Threading . Tasks ;
88using Microsoft . AspNetCore . Http ;
9+ using Microsoft . AspNetCore . Mvc ;
910using Microsoft . AspNetCore . Mvc . Formatters ;
10- using Microsoft . Extensions . Options ;
1111using Moq ;
1212using Newtonsoft . Json ;
1313using PartialResponse . Core ;
@@ -19,8 +19,8 @@ public class PartialJsonOutputFormatterTests
1919 {
2020 private readonly PartialJsonOutputFormatter formatter ;
2121 private readonly IFieldsParser fieldsParser = Mock . Of < IFieldsParser > ( ) ;
22- private readonly IOptions < MvcPartialJsonOptions > options = Mock . Of < IOptions < MvcPartialJsonOptions > > ( ) ;
23- private readonly MvcPartialJsonOptions partialJsonOptions = new MvcPartialJsonOptions ( ) ;
22+ private readonly MvcPartialJsonOptions mvcPartialJsonOptions = new MvcPartialJsonOptions ( ) ;
23+ private readonly MvcOptions mvcOptions = new MvcOptions ( ) ;
2424 private readonly HttpContext httpContext = Mock . Of < HttpContext > ( ) ;
2525 private readonly Dictionary < object , object > httpContextItems = new Dictionary < object , object > ( ) ;
2626 private readonly HttpRequest httpRequest = Mock . Of < HttpRequest > ( ) ;
@@ -45,11 +45,11 @@ public PartialJsonOutputFormatterTests()
4545 . SetupGet ( httpRequest => httpRequest . HttpContext )
4646 . Returns ( this . httpContext ) ;
4747
48- Mock . Get ( this . options )
49- . SetupGet ( options => options . Value )
50- . Returns ( this . partialJsonOptions ) ;
51-
52- this . formatter = new PartialJsonOutputFormatter ( new JsonSerializerSettings ( ) , this . fieldsParser , Mock . Of < ArrayPool < char > > ( ) , this . partialJsonOptions ) ;
48+ #if ASPNETCORE2
49+ this . formatter = new PartialJsonOutputFormatter ( new JsonSerializerSettings ( ) , this . fieldsParser , Mock . Of < ArrayPool < char > > ( ) , this . mvcPartialJsonOptions ) ;
50+ #else
51+ this . formatter = new PartialJsonOutputFormatter ( new JsonSerializerSettings ( ) , this . fieldsParser , Mock . Of < ArrayPool < char > > ( ) , this . mvcPartialJsonOptions , this . mvcOptions ) ;
52+ #endif
5353 }
5454
5555 [ Fact ]
@@ -64,8 +64,8 @@ public async Task TheWriteResponseBodyAsyncMethodShouldReturnStatusCode400IfFiel
6464 . Setup ( fieldsParser => fieldsParser . Parse ( this . httpRequest ) )
6565 . Returns ( FieldsParserResult . Failed ( ) ) ;
6666
67- this . partialJsonOptions . IgnoreParseErrors = false ;
68- this . partialJsonOptions . IgnoreCase = false ;
67+ this . mvcPartialJsonOptions . IgnoreParseErrors = false ;
68+ this . mvcPartialJsonOptions . IgnoreCase = false ;
6969
7070 var writeContext = this . CreateWriteContext ( new { } ) ;
7171
@@ -91,8 +91,8 @@ public async Task TheWriteResponseBodyAsyncMethodShouldNotReturnStatusCode400IfF
9191 . Setup ( fieldsParser => fieldsParser . Parse ( this . httpRequest ) )
9292 . Returns ( FieldsParserResult . Failed ( ) ) ;
9393
94- this . partialJsonOptions . IgnoreParseErrors = true ;
95- this . partialJsonOptions . IgnoreCase = false ;
94+ this . mvcPartialJsonOptions . IgnoreParseErrors = true ;
95+ this . mvcPartialJsonOptions . IgnoreCase = false ;
9696
9797 var writeContext = this . CreateWriteContext ( new { foo = "bar" } ) ;
9898
@@ -164,7 +164,7 @@ public async Task TheWriteResponseBodyAsyncMethodShouldIgnoreCase()
164164 . Setup ( fieldsParser => fieldsParser . Parse ( this . httpRequest ) )
165165 . Returns ( FieldsParserResult . Success ( fields ) ) ;
166166
167- this . partialJsonOptions . IgnoreCase = true ;
167+ this . mvcPartialJsonOptions . IgnoreCase = true ;
168168
169169 var writeContext = this . CreateWriteContext ( new { foo = "bar" } ) ;
170170
@@ -189,7 +189,7 @@ public async Task TheWriteResponseBodyAsyncMethodShouldNotIgnoreCase()
189189 . Setup ( fieldsParser => fieldsParser . Parse ( this . httpRequest ) )
190190 . Returns ( FieldsParserResult . Success ( fields ) ) ;
191191
192- this . partialJsonOptions . IgnoreCase = false ;
192+ this . mvcPartialJsonOptions . IgnoreCase = false ;
193193
194194 var writeContext = this . CreateWriteContext ( new { foo = "bar" } ) ;
195195
0 commit comments