public void GetRequiredBinderThrowsIfNoProviderMatches() { // Arrange ControllerContext controllerContext = new ControllerContext(); ExtensibleModelBindingContext bindingContext = new ExtensibleModelBindingContext { ModelMetadata = new EmptyModelMetadataProvider().GetMetadataForType( null, typeof(int) ) }; ModelBinderProviderCollection collection = new ModelBinderProviderCollection( new[] { new Mock <ModelBinderProvider>().Object, } ); // Act & assert Assert.Throws <InvalidOperationException>( delegate { collection.GetRequiredBinder(controllerContext, bindingContext); }, @"A binder for type System.Int32 could not be located." ); }