public void Setup_SetsUpModelBinders() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Configure(mvcOptions); // Assert var i = 0; Assert.Equal(13, mvcOptions.ModelBinders.Count); Assert.IsType(typeof(BinderTypeBasedModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(ServicesModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(BodyModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(HeaderModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(TypeConverterModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(TypeMatchModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(CancellationTokenModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(ByteArrayModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(FormFileModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(FormCollectionModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(GenericModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(MutableObjectModelBinder), mvcOptions.ModelBinders[i++]); Assert.IsType(typeof(ComplexModelDtoModelBinder), mvcOptions.ModelBinders[i++]); }
private static void MVCOptionsConfigs(MvcOptions opts) { opts.OutputFormatters.Clear(); JsonSerializerSettings jsonSettings = new JsonSerializerSettings(); jsonSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); opts.OutputFormatters.Add(new JsonOutputFormatter(jsonSettings)); }
private IServiceProvider CreateServices() { var services = new Mock<IServiceProvider>(MockBehavior.Strict); var options = new MvcOptions(); options.OutputFormatters.Add(new JsonOutputFormatter()); var optionsAccessor = new Mock<IOptions<MvcOptions>>(); optionsAccessor.SetupGet(o => o.Options) .Returns(options); var mockActionBindingContext = new Mock<IScopedInstance<ActionBindingContext>>(); var bindingContext = new ActionBindingContext { OutputFormatters = options.OutputFormatters }; mockActionBindingContext .SetupGet(o => o.Value) .Returns(bindingContext); services.Setup(o => o.GetService(typeof(IScopedInstance<ActionBindingContext>))) .Returns(mockActionBindingContext.Object); services.Setup(s => s.GetService(typeof(IOptions<MvcOptions>))) .Returns(optionsAccessor.Object); services.Setup(s => s.GetService(typeof(ILogger<ObjectResult>))) .Returns(new Mock<ILogger<ObjectResult>>().Object); return services.Object; }
/// <summary> /// Configures the input and output formatters. /// </summary> /// <param name="outputFormatters">A collection of output formatters.</param> private static void ConfigureFormatters(MvcOptions mvcOptions) { // Configures the JSON output formatter to use camel case property names like 'propertyName' instead of // pascal case 'PropertyName' as this is the more common JavaScript/JSON style. JsonOutputFormatter jsonOutputFormatter = mvcOptions.OutputFormatters .OfType<JsonOutputFormatter>() .First(); jsonOutputFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // Adds the BSON input and output formatters mvcOptions.AddBsonSerializerFormatter(); // Configures the BSON output formatter to use camel case property names like 'propertyName' instead of // pascal case 'PropertyName' as this is the more common JavaScript/JSON/BSON style. BsonOutputFormatter bsonOutputFormatter = mvcOptions.OutputFormatters .OfType<BsonOutputFormatter>() .First(); bsonOutputFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // Adds the XML input and output formatter. mvcOptions.AddXmlDataContractSerializerFormatter(); // Force 204 No Content response, when returning null values. // Note that we are inserting this at the top of the formatters collection so we can select a formatter // quickly in this case. mvcOptions.OutputFormatters.Insert(0, new HttpNoContentOutputFormatter()); // Force 406 Not Acceptable responses if the media type is not supported, instead of returning the default. // Note that we are inserting this near the top of the formatters collection so we can select a formatter // quickly in this case. mvcOptions.OutputFormatters.Insert(1, new HttpNotAcceptableOutputFormatter()); }
/// <summary> /// Configures the JSON output formatter to use camel case property names like 'propertyName' instead of pascal /// case 'PropertyName' as this is the more common JavaScript/JSON style. Also adds the XML input and output /// formatters. See: http://www.strathweb.com/2015/04/asp-net-mvc-6-formatters-xml-browser-requests/. /// </summary> /// <param name="outputFormatters">A collection of output formatters.</param> private static void ConfigureFormatters(MvcOptions mvcOptions) { JsonOutputFormatter jsonOutputFormatter = mvcOptions.OutputFormatters .OfType<JsonOutputFormatter>() .First(); jsonOutputFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); mvcOptions.AddXmlDataContractSerializerFormatter(); }
public DefaultControllerActionArgumentBinder( IModelMetadataProvider modelMetadataProvider, IObjectModelValidator validator, IOptions<MvcOptions> optionsAccessor) { _modelMetadataProvider = modelMetadataProvider; _options = optionsAccessor.Options; _validator = validator; }
public void MaxValidationError_ThrowsIfValueIsOutOfRange() { // Arrange var options = new MvcOptions(); // Act & Assert var ex = Assert.Throws<ArgumentOutOfRangeException>(() => options.MaxModelValidationErrors = -1); Assert.Equal("value", ex.ParamName); }
/// <summary> /// Configures the input and output formatters. /// </summary> /// <param name="outputFormatters">A collection of output formatters.</param> private static void ConfigureFormatters(MvcOptions mvcOptions) { // Configures the JSON output formatter to use camel case property names like 'propertyName' instead of // pascal case 'PropertyName' as this is the more common JavaScript/JSON style. JsonOutputFormatter jsonOutputFormatter = mvcOptions.OutputFormatters .OfType<JsonOutputFormatter>() .First(); jsonOutputFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }
//使用lamda配置路由 一般用于api路由 public void Route(MvcOptions opt) { opt.EnableTypedRouting(); opt.Get("api/user", c => c.Action<UserController>(x => x.List())); opt.Post("api/user", c => c.Action<UserController>(x => x.Add())); opt.Delete("api/user", c => c.Action<UserController>(x => x.Remove())); opt.Put("api/user", c => c.Action<UserController>(x => x.Update())); opt.Post("api/user/portrait", c => c.Action<UserController>(x => x.UploadPortrait(Param<IFormFileCollection>.Any))); }
public void InputviewEngines_InstanceOf_ThrowsInvalidOperationExceptionIfNoInstance() { // Arrange var viewEngines = new MvcOptions().ViewEngines; viewEngines.Add(Mock.Of<IViewEngine>()); viewEngines.Add(typeof(TestViewEngine)); // Act & Assert Assert.Throws<InvalidOperationException>(() => viewEngines.InstanceOf<TestViewEngine>()); }
public void ThrowsWhenMultipleCacheProfilesWithSameNameAreAdded() { // Arrange var options = new MvcOptions(); options.CacheProfiles.Add("HelloWorld", new CacheProfile { Duration = 10 }); // Act & Assert var ex = Assert.Throws<ArgumentException>( () => options.CacheProfiles.Add("HelloWorld", new CacheProfile { Duration = 5 })); Assert.Equal("An item with the same key has already been added.", ex.Message); }
public void Setup_SetsUpViewEngines() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Configure(mvcOptions); // Assert Assert.Equal(1, mvcOptions.ViewEngines.Count); Assert.Equal(typeof(RazorViewEngine), mvcOptions.ViewEngines[0].ViewEngineType); }
public void Setup_SetsUpOutputFormatters() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Setup(mvcOptions); // Assert Assert.Equal(2, mvcOptions.OutputFormatters.Count); Assert.IsType<TextPlainFormatter>(mvcOptions.OutputFormatters[0].Instance); Assert.IsType<JsonOutputFormatter>(mvcOptions.OutputFormatters[1].Instance); }
public void ValueProviderFactories_RemoveTypesOf_RemovesDescriptorsOfIValueProviderFactory() { // Arrange var factories = new MvcOptions().ValueProviderFactories; factories.Add(new FormValueProviderFactory()); factories.Add(Mock.Of<IValueProviderFactory>()); factories.Add(typeof(FormValueProviderFactory)); factories.Add(Mock.Of<IValueProviderFactory>()); // Act factories.RemoveTypesOf<FormValueProviderFactory>(); // Assert Assert.DoesNotContain(factories, descriptor => descriptor.OptionType == typeof(FormValueProviderFactory)); }
/// <summary> /// Configures the input and output formatters. /// </summary> private static void ConfigureFormatters(MvcOptions mvcOptions) { // $Start-NoContentFormatter$ // Force 204 No Content response, when returning null values. // Note that we are inserting this at the top of the formatters collection so we can select a formatter // quickly in this case. mvcOptions.OutputFormatters.Insert(0, new HttpNoContentOutputFormatter()); // $End-NoContentFormatter$ // $Start-NotAcceptableFormatter$ // Force 406 Not Acceptable responses if the media type is not supported, instead of returning the default. // Note that we are inserting this near the top of the formatters collection so we can select a formatter // quickly in this case. mvcOptions.OutputFormatters.Insert(1, new HttpNotAcceptableOutputFormatter()); // $End-NotAcceptableFormatter$ }
public void ModelBinders_RemoveTypesOf_RemovesDescriptorsOfIModelBinder() { // Arrange var modelBinders = new MvcOptions().ModelBinders; modelBinders.Add(new ByteArrayModelBinder()); modelBinders.Add(Mock.Of<IModelBinder>()); modelBinders.Add(typeof(ByteArrayModelBinder)); modelBinders.Add(Mock.Of<IModelBinder>()); // Act modelBinders.RemoveTypesOf<ByteArrayModelBinder>(); // Assert Assert.DoesNotContain(modelBinders, descriptor => descriptor.OptionType == typeof(ByteArrayModelBinder)); }
public void Setup_SetsUpOutputFormatters() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.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]); }
public void Setup_SetsUpValueProviders() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Configure(mvcOptions); // Assert var valueProviders = mvcOptions.ValueProviderFactories; Assert.Equal(3, valueProviders.Count); Assert.IsType<RouteValueValueProviderFactory>(valueProviders[0]); Assert.IsType<QueryStringValueProviderFactory>(valueProviders[1]); Assert.IsType<FormValueProviderFactory>(valueProviders[2]); }
public void Setup_SetsUpModelBinders() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Setup(mvcOptions); // Assert Assert.Equal(5, mvcOptions.ModelBinders.Count); Assert.Equal(typeof(TypeConverterModelBinder), mvcOptions.ModelBinders[0].OptionType); Assert.Equal(typeof(TypeMatchModelBinder), mvcOptions.ModelBinders[1].OptionType); Assert.Equal(typeof(GenericModelBinder), mvcOptions.ModelBinders[2].OptionType); Assert.Equal(typeof(MutableObjectModelBinder), mvcOptions.ModelBinders[3].OptionType); Assert.Equal(typeof(ComplexModelDtoModelBinder), mvcOptions.ModelBinders[4].OptionType); }
public void DefaultControllerModelConvention_AppliesToAllControllers() { // Arrange var options = new MvcOptions(); var app = new ApplicationModel(); app.Controllers.Add(new ControllerModel(typeof(HelloController).GetTypeInfo(), new List<object>())); app.Controllers.Add(new ControllerModel(typeof(WorldController).GetTypeInfo(), new List<object>())); options.Conventions.Add(new SimpleControllerConvention()); // Act options.Conventions[0].Apply(app); // Assert foreach (var controller in app.Controllers) { Assert.True(controller.Properties.ContainsKey("TestProperty")); } }
/// <summary> /// Initialises a new instance of <see cref="DefaultWidgetArgumentBinder"/>. /// </summary> /// <param name="options">The options accessor for <see cref="MvcOptions"/></param> /// <param name="modelMetadataProvider">The model metadata provider.</param> /// <param name="objectModelValidator">The object model validator.</param> public DefaultWidgetArgumentBinder(IOptions<MvcOptions> options, IModelMetadataProvider modelMetadataProvider, IObjectModelValidator objectModelValidator) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (modelMetadataProvider == null) { throw new ArgumentNullException(nameof(modelMetadataProvider)); } if (objectModelValidator == null) { throw new ArgumentNullException(nameof(objectModelValidator)); } _options = options.Value; _modelMetadataProvider = modelMetadataProvider; _objectModelValidator = objectModelValidator; }
private void ConfigureMvc(MvcOptions options) { options.CacheProfiles.Add(Constants.CacheProfileName, new CacheProfile() { Duration = Configuration.Get("CacheDuration", 10), VaryByHeader = "Accept" } ); var jsonOutputFormatter = new JsonOutputFormatter { SerializerSettings = { ContractResolver = new CamelCasePropertyNamesContractResolver(), DefaultValueHandling = DefaultValueHandling.Include } }; options.OutputFormatters.RemoveType<JsonOutputFormatter>(); options.OutputFormatters.Insert(0, jsonOutputFormatter); }
/// <summary> /// Configures the input and output formatters. /// </summary> /// <param name="outputFormatters">A collection of output formatters.</param> private static void ConfigureFormatters(MvcOptions mvcOptions) { // Configures the JSON output formatter to use camel case property names like 'propertyName' instead of // pascal case 'PropertyName' as this is the more common JavaScript/JSON style. JsonOutputFormatter jsonOutputFormatter = mvcOptions.OutputFormatters .OfType<JsonOutputFormatter>() .First(); jsonOutputFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // Add the XML input and output formatters. // See: http://www.strathweb.com/2015/04/asp-net-mvc-6-formatters-xml-browser-requests/. mvcOptions.AddXmlDataContractSerializerFormatter(); // TODO: Add the BSON input and output formatters. // Force 204 No Content response, when returning null values. mvcOptions.OutputFormatters.Insert(0, new HttpNoContentOutputFormatter()); // Force 406 Not Acceptable responses if the media type is not supported, instead of returning the default. mvcOptions.OutputFormatters.Insert(0, new HttpNotAcceptableOutputFormatter()); }
public void Setup_SetsUpExcludeFromValidationDelegates() { // Arrange var mvcOptions = new MvcOptions(); var setup1 = new CoreMvcOptionsSetup(); var setup2 = new MvcOptionsSetup(); // Act setup1.Configure(mvcOptions); setup2.Configure(mvcOptions); // Assert Assert.Equal(8, mvcOptions.ValidationExcludeFilters.Count); var i = 0; // Verify if the delegates registered by default exclude the given types. Assert.IsType(typeof(SimpleTypesExcludeFilter), mvcOptions.ValidationExcludeFilters[i++]); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var typeFilter = Assert.IsType <DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(typeFilter.ExcludedType, typeof(Type)); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var cancellationTokenFilter = Assert.IsType <DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(cancellationTokenFilter.ExcludedType, typeof(System.Threading.CancellationToken)); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var formFileFilter = Assert.IsType <DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(formFileFilter.ExcludedType, typeof(Http.IFormFile)); Assert.IsType( typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var formCollectionFilter = Assert.IsType <DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(formCollectionFilter.ExcludedType, typeof(Http.IFormCollection)); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var xObjectFilter = Assert.IsType <DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(xObjectFilter.ExcludedType, typeof(XObject)); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var jTokenFilter = Assert.IsType <DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(jTokenFilter.ExcludedType, typeof(JToken)); Assert.IsType(typeof(DefaultTypeNameBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var xmlNodeFilter = Assert.IsType <DefaultTypeNameBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(xmlNodeFilter.ExcludedTypeName, "System.Xml.XmlNode"); }
private static IServiceProvider GetServiceProvider() { var optionsSetup = new MvcOptionsSetup(); var options = new MvcOptions(); optionsSetup.Configure(options); var optionsAccessor = new Mock<IOptions<MvcOptions>>(); optionsAccessor.SetupGet(o => o.Options).Returns(options); var serviceCollection = new ServiceCollection(); serviceCollection.AddInstance(optionsAccessor.Object); return serviceCollection.BuildServiceProvider(); }
public void Setup_SetsUpInputFormatters() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Configure(mvcOptions); // Assert Assert.Equal(2, mvcOptions.InputFormatters.Count); Assert.IsType<JsonInputFormatter>(mvcOptions.InputFormatters[0]); Assert.IsType<JsonPatchInputFormatter>(mvcOptions.InputFormatters[1]); }
private ControllerActionDescriptorProvider CreateProvider() { var assemblyProvider = new StaticAssemblyProvider(); assemblyProvider.CandidateAssemblies.Add(GetType().GetTypeInfo().Assembly); var controllerTypeProvider = new NamespaceFilteredControllerTypeProvider(assemblyProvider); var options = new MvcOptions(); var setup = new WebApiCompatShimOptionsSetup(); setup.Configure(options); var optionsAccessor = new Mock<IOptions<MvcOptions>>(); optionsAccessor .SetupGet(o => o.Value) .Returns(options); var authorizationOptionsAccessor = new Mock<IOptions<AuthorizationOptions>>(); authorizationOptionsAccessor .SetupGet(o => o.Value) .Returns(new AuthorizationOptions()); var modelProvider = new DefaultApplicationModelProvider(optionsAccessor.Object); var provider = new ControllerActionDescriptorProvider( controllerTypeProvider, new[] { modelProvider }, optionsAccessor.Object); return provider; }
public void Setup_JsonFormattersUseSerializerSettings() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Configure(mvcOptions); // Assert var jsonInputFormatters = mvcOptions.InputFormatters.OfType<JsonInputFormatter>(); foreach (var jsonInputFormatter in jsonInputFormatters) { Assert.Same(mvcOptions.SerializerSettings, jsonInputFormatter.SerializerSettings); } var jsonOuputFormatters = mvcOptions.OutputFormatters.OfType<JsonOutputFormatter>(); foreach (var jsonOuputFormatter in jsonOuputFormatters) { Assert.Same(mvcOptions.SerializerSettings, jsonOuputFormatter.SerializerSettings); } }
public void Setup_SetsUpExcludeFromValidationDelegates() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Configure(mvcOptions); // Assert Assert.Equal(8, mvcOptions.ValidationExcludeFilters.Count); var i = 0; // Verify if the delegates registered by default exclude the given types. Assert.IsType(typeof(SimpleTypesExcludeFilter), mvcOptions.ValidationExcludeFilters[i++]); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var xObjectFilter = Assert.IsType<DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(xObjectFilter.ExcludedType, typeof(XObject)); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var typeFilter = Assert.IsType<DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(typeFilter.ExcludedType, typeof(Type)); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var jTokenFilter = Assert.IsType<DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(jTokenFilter.ExcludedType, typeof(JToken)); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var cancellationTokenFilter = Assert.IsType<DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(cancellationTokenFilter.ExcludedType, typeof(System.Threading.CancellationToken)); Assert.IsType(typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var formFileFilter = Assert.IsType<DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(formFileFilter.ExcludedType, typeof(Http.IFormFile)); Assert.IsType( typeof(DefaultTypeBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var formCollectionFilter = Assert.IsType<DefaultTypeBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(formCollectionFilter.ExcludedType, typeof(Http.IFormCollection)); Assert.IsType(typeof(DefaultTypeNameBasedExcludeFilter), mvcOptions.ValidationExcludeFilters[i]); var xmlNodeFilter = Assert.IsType<DefaultTypeNameBasedExcludeFilter>(mvcOptions.ValidationExcludeFilters[i++]); Assert.Equal(xmlNodeFilter.ExcludedTypeName, "System.Xml.XmlNode"); }
public void Setup_IgnoresAcceptHeaderHavingWildCardMediaAndSubMediaTypes() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Configure(mvcOptions); // Assert Assert.False(mvcOptions.RespectBrowserAcceptHeader); }
public void Setup_SetsUpClientModelValidatorProviders() { // Arrange var mvcOptions = new MvcOptions(); var setup = new MvcOptionsSetup(); // Act setup.Configure(mvcOptions); // Assert Assert.Equal(2, mvcOptions.ClientModelValidatorProviders.Count); Assert.IsType<DefaultClientModelValidatorProvider>(mvcOptions.ClientModelValidatorProviders[0]); Assert.IsType<DataAnnotationsClientModelValidatorProvider>(mvcOptions.ClientModelValidatorProviders[1]); }