public void Setup_JsonFormattersUseSerializerSettings() { // Arrange var jsonOptionsAccessor = new OptionsManager <MvcJsonOptions>( Enumerable.Empty <IConfigureOptions <MvcJsonOptions> >()); var mvcOptions = new MvcOptions(); var setup = new JsonMvcOptionsSetup(jsonOptionsAccessor); // Act setup.Configure(mvcOptions); // Assert var jsonInputFormatters = mvcOptions.InputFormatters.OfType <JsonInputFormatter>(); foreach (var jsonInputFormatter in jsonInputFormatters) { Assert.Same(jsonOptionsAccessor.Options.SerializerSettings, jsonInputFormatter.SerializerSettings); } var jsonOuputFormatters = mvcOptions.OutputFormatters.OfType <JsonOutputFormatter>(); foreach (var jsonOuputFormatter in jsonOuputFormatters) { Assert.Same(jsonOptionsAccessor.Options.SerializerSettings, jsonOuputFormatter.SerializerSettings); } }
public void Setup_SetsUpInputFormatters() { // Arrange var mvcOptions = new MvcOptions(); var setup1 = new CoreMvcOptionsSetup(); var setup2 = new MvcOptionsSetup(); var setup3 = new JsonMvcOptionsSetup(new OptionsManager <MvcJsonOptions>( Enumerable.Empty <IConfigureOptions <MvcJsonOptions> >())); // Act setup1.Configure(mvcOptions); setup2.Configure(mvcOptions); setup3.Configure(mvcOptions); // Assert Assert.Equal(2, mvcOptions.InputFormatters.Count); Assert.IsType <JsonInputFormatter>(mvcOptions.InputFormatters[0]); Assert.IsType <JsonPatchInputFormatter>(mvcOptions.InputFormatters[1]); }
public void Setup_SetsUpOutputFormatters() { // Arrange var mvcOptions = new MvcOptions(); var setup1 = new CoreMvcOptionsSetup(); var setup2 = new MvcOptionsSetup(); var setup3 = new JsonMvcOptionsSetup(new OptionsManager <MvcJsonOptions>( Enumerable.Empty <IConfigureOptions <MvcJsonOptions> >())); // Act setup1.Configure(mvcOptions); setup2.Configure(mvcOptions); setup3.Configure(mvcOptions); // Assert Assert.Equal(4, mvcOptions.OutputFormatters.Count); Assert.IsType <HttpNoContentOutputFormatter>(mvcOptions.OutputFormatters[0]); Assert.IsType <StringOutputFormatter>(mvcOptions.OutputFormatters[1]); Assert.IsType <StreamOutputFormatter>(mvcOptions.OutputFormatters[2]); Assert.IsType <JsonOutputFormatter>(mvcOptions.OutputFormatters[3]); }