public void CanBindToGenericList() { int expectedValue = 32; DataBinder binder = new DataBinder(); CompositeNode paramsNode = GetParamsNode(expectedValue); List<int> myList = (List<int>) binder.BindObject(typeof(List<int>), "myList", paramsNode); Assert.AreEqual(expectedValue, myList[0]); }
public void CanBindToGenericListInstance() { int expectedValue = 12; List<int> myList = new List<int>(); myList.Add(expectedValue); DataBinder binder = new DataBinder(); CompositeNode paramsNode = GetParamsNode(expectedValue); binder.BindObjectInstance(myList, "myList", paramsNode); Assert.AreEqual(expectedValue, myList[0]); }
public void When_the_controller_implements_ICastleBindingContainer_and_the_binder_is_already_set_then_it_should_be_used() { var castleBinder = new DataBinder(); var controller = new CastleBindableController {Binder = castleBinder}; _context = CreateControllerContext(controller); _context.HttpContext.Request.Form["cust.Id"] = "Fail"; var binder = new CastleBindAttribute(); binder.BindModel(_context, CreateContext("cust", typeof(Customer))); Assert.That(controller.Binder, Is.SameAs(castleBinder)); Assert.That(castleBinder.ErrorList["Id"], Is.Not.Null); }