public void RegisterBinderForGenericType_Instance() { // Arrange ModelBinderProvider mockProvider = new Mock <ModelBinderProvider>().Object; IExtensibleModelBinder mockBinder = new Mock <IExtensibleModelBinder>().Object; ModelBinderProviderCollection collection = new ModelBinderProviderCollection { mockProvider }; // Act collection.RegisterBinderForGenericType(typeof(List <>), mockBinder); // Assert var genericProvider = Assert.IsType <GenericModelBinderProvider>(collection[0]); Assert.Equal(typeof(List <>), genericProvider.ModelType); Assert.Equal(mockProvider, collection[1]); }
public void RegisterBinderForGenericType_Instance() { // Arrange ModelBinderProvider mockProvider = new Mock <ModelBinderProvider>().Object; IExtensibleModelBinder mockBinder = new Mock <IExtensibleModelBinder>().Object; ModelBinderProviderCollection collection = new ModelBinderProviderCollection() { mockProvider }; // Act collection.RegisterBinderForGenericType(typeof(List <>), mockBinder); // Assert GenericModelBinderProvider genericProvider = collection[0] as GenericModelBinderProvider; Assert.IsNotNull(genericProvider, "Generic provider should've been inserted at the front of the list."); Assert.AreEqual(typeof(List <>), genericProvider.ModelType); Assert.AreEqual(mockProvider, collection[1]); }