public void SetItem()
        {
            // Arrange
            ModelBinderProvider provider0 = new Mock <ModelBinderProvider>().Object;
            ModelBinderProvider provider1 = new Mock <ModelBinderProvider>().Object;
            ModelBinderProvider provider2 = new Mock <ModelBinderProvider>().Object;

            ModelBinderProviderCollection collection = new ModelBinderProviderCollection();

            collection.Add(provider0);
            collection.Add(provider1);

            // Act
            collection[1] = provider2;

            // Assert
            Assert.Equal(new[] { provider0, provider2 }, collection.ToArray());
        }
        public void AddNullProviderThrows()
        {
            // Arrange
            ModelBinderProviderCollection collection = new ModelBinderProviderCollection();

            // Act & Assert
            Assert.ThrowsArgumentNull(
                delegate { collection.Add(null); },
                "item");
        }
Exemplo n.º 3
0
 public virtual void RegisterModelBinders(ModelBinderProviderCollection providers, ModelBinderDictionary binders)
 {
     foreach (var p in BinderProviders)
     {
         providers.Add(p);
     }
     foreach (var b in Binders)
     {
         binders.Add(b.Metadata.TargetType, b.Value);
     }
 }
        public void SetNullProviderThrows()
        {
            // Arrange
            ModelBinderProviderCollection collection = new ModelBinderProviderCollection();

            collection.Add(new Mock <ModelBinderProvider>().Object);

            // Act & Assert
            Assert.ThrowsArgumentNull(
                delegate { collection[0] = null; },
                "item");
        }
Exemplo n.º 5
0
        public void AddNullProviderThrows()
        {
            // Arrange
            ModelBinderProviderCollection collection = new ModelBinderProviderCollection();

            // Act & Assert
            ExceptionHelper.ExpectArgumentNullException(
                delegate {
                collection.Add(null);
            },
                "item");
        }
Exemplo n.º 6
0
 public static void Configure(ModelBinderProviderCollection binders)
 {
     binders.Add(new QuestionModelBinderProvider());
     binders.Add(new CustomCancellationTokenModelBinder());
 }
Exemplo n.º 7
0
 public static void RegisterBinderProviders(ModelBinderProviderCollection binderProviders)
 {
     binderProviders.Add(new EntityBinder());
 }
 internal static void RegisterModelBinders(ModelBinderProviderCollection modelBinderProviderCollection)
 {
     modelBinderProviderCollection.Add(new EntityModelBinderProvider());
 }