Created
December 31, 2012 21:35
-
-
Save anonymous/4422887 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void Should_bind_to_IEnumerable_T_from_form() | |
{ | |
//Given | |
var typeConverters = new ITypeConverter[] { new CollectionConverter(), new FallbackConverter(), }; | |
var binder = this.GetBinder(typeConverters); | |
var context = CreateContextWithHeader("Content-Type", new[] { "application/x-www-form-urlencoded" }); | |
context.Request.Form["StringProperty_1"] = "Test"; | |
context.Request.Form["IntProperty_1"] = "1"; | |
context.Request.Form["StringProperty_2"] = "Test2"; | |
context.Request.Form["IntProperty_2"] = "2"; | |
// When | |
var result = (IEnumerable<TestModel>)binder.Bind(context, typeof(IEnumerable<TestModel>), null, new BindingConfig()); | |
// Then | |
result.First().StringProperty.ShouldEqual("Test"); | |
result.First().IntProperty.ShouldEqual(1); | |
result.Last().StringProperty.ShouldEqual("Test2"); | |
result.Last().IntProperty.ShouldEqual(2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment