private void Initialize( Mock <HttpContext> httpContext, string format = null, FormatSource?place = null) { OptionsManager = Options.Create(new MvcOptions()); // Setup options on mock service provider MvcOptions = OptionsManager.Value; // Set up default output formatters. MvcOptions.OutputFormatters.Add(new HttpNoContentOutputFormatter()); MvcOptions.OutputFormatters.Add(new StringOutputFormatter()); MvcOptions.OutputFormatters.Add(SystemTextJsonOutputFormatter.CreateFormatter(new JsonOptions())); // Set up default mapping for json extensions to content type MvcOptions.FormatterMappings.SetMediaTypeMappingForFormat( "json", MediaTypeHeaderValue.Parse("application/json")); // Setup MVC services on mock service provider MockActionContext = CreateMockActionContext(httpContext, format, place); }
protected override TextOutputFormatter GetOutputFormatter() { return(SystemTextJsonOutputFormatter.CreateFormatter(new JsonOptions())); }