public async Task BindSimpleCollection_RawValueIsEmptyCollection_ReturnsEmptyList() { // Arrange var binder = new CollectionModelBinder <int>(CreateIntBinder(), NullLoggerFactory.Instance); var context = GetModelBindingContext(new SimpleValueProvider()); // Act var boundCollection = await binder.BindSimpleCollection(context, new ValueProviderResult(new string[0])); // Assert Assert.NotNull(boundCollection.Model); Assert.Empty(boundCollection.Model); }
public async Task BindSimpleCollection_SubBindingSucceeds() { // Arrange var culture = new CultureInfo("fr-FR"); var bindingContext = GetModelBindingContext(new SimpleValueProvider()); var elementBinder = new StubModelBinder(mbc => { Assert.Equal("someName", mbc.ModelName); mbc.Result = ModelBindingResult.Success(42); }); var modelBinder = new CollectionModelBinder <int>(elementBinder, NullLoggerFactory.Instance); // Act var boundCollection = await modelBinder.BindSimpleCollection( bindingContext, new ValueProviderResult(new string[] { "0" })); // Assert Assert.Equal(new[] { 42 }, boundCollection.Model.ToArray()); }