public void When_constructed_with_an_expression_then_items_binder_is_bound_to_the_control()
 {
     var view = new OrderView();
     var vm = new OrderViewModel();
     var binder = new ListBinder<string,OrderViewModel>(p => p.Customers, view,vm);
     Assert.AreEqual(view.Customers, binder.ViewElement);
 }
 public void When_constructed_with_an_expression_then_item_binder_is_bound_to_vm_selectedItem()
 {
     var view = new OrderView();
     var vm = new OrderViewModel();
     var binder = new ListBinder<string,OrderViewModel>(p => p.Customers, view,vm);
     Assert.AreEqual("SelectedCustomer", binder.SelectedItemBinder.TargetPath);
 }
 public void When_constructed_then_view_model_is_set_on_view()
 {
     OrderView view = new OrderView();
     OrderViewModel vm = new OrderViewModel();
     var vmBinder = ConventionalViewBinder<OrderViewModel>.For(view, vm);
     Assert.AreEqual(vm, view.GetValue(ViewBinder.ModelProperty));
 }
 public void When_constructed_with_an_expression_then_items_binder_is_bound_to_items_source_property()
 {
     var view = new OrderView();
     var vm = new OrderViewModel();
     var binder = new ListBinder<string, OrderViewModel>(p => p.Customers, view, vm);
     Assert.AreEqual(ListBox.ItemsSourceProperty,binder.ItemsBinder.Property);
 }
 public void When_constructed_then_value_binder_is_created_for_FirstName()
 {
     OrderView view = new OrderView();
     OrderViewModel vm = new OrderViewModel();
     var vmBinder = ConventionalViewBinder.For(view, vm);
     var firstNameBinder = vmBinder.GetPropertyBinder(view.FirstName, TextBox.TextProperty);
     Assert.IsNotNull(firstNameBinder);
 }
 public void When_constructed_then_method_binder_is_created_for_Save_button()
 {
     OrderView view = new OrderView();
     OrderViewModel vm = new OrderViewModel();
     var vmBinder = ConventionalViewBinder.For(view, vm);
     var saveBinder = vmBinder.GetMethodBinder(view.Save, "Click");
     Assert.IsNotNull(saveBinder);
 }
 public void When_constructed_then_list_binder_is_created_for_Customers()
 {
     OrderView view = new OrderView();
     OrderViewModel vm = new OrderViewModel();
     var vmBinder = ConventionalViewBinder.For(view, vm);
     var customersBinder = vmBinder.GetPropertyBinder(view.Customers, ListBox.ItemsSourceProperty);
     Assert.IsNotNull(customersBinder);
 }
 public void When_constructed_with_property_expression_then_property_is_set_to_default_property()
 {
     var vm = new OrderViewModel();
     var view = new OrderView();
     var definition = new ValueBinderDefinition<OrderViewModel>(p => p.FirstName);
     definition.Create(view, vm);
     Assert.AreEqual(TextBox.TextProperty, definition.Property);
 }
 public void When_constructed_then_list_binder_for_customers_is_generic_collection_of_string()
 {
     OrderView view = new OrderView();
     OrderViewModel vm = new OrderViewModel();
     var vmBinder = ConventionalViewBinder.For(view, vm);
     var customersBinder = vmBinder.GetPropertyBinder(view.Customers, ListBox.ItemsSourceProperty);
     var binderType = customersBinder.GetType();
     Assert.IsTrue(binderType.IsAssignableFrom(typeof(ListBinder<string,OrderViewModel>)));
 }
        public void When_adding_a_value_and_passing_the_element_and_the_source_property_then_value_binder_is_created()
        {
            var vm = new OrderViewModel { FirstName = "Jeff" };
            var view = new OrderView();
            var viewBinder = ViewBinder.For(view, vm).
                Value(view.FirstName, TextBox.TextProperty, p => vm.FirstName);

            var binder = viewBinder.GetBinders<IValueBinder>("FirstName").First();
            Assert.IsNotNull(binder);
        }
        public void When_adding_an_action_and_passing_the_control_and_the_is_enabled_then_method_binder_is_created()
        {
            var vm = new OrderViewModel();
            var view = new OrderView();
            var viewBinder = ViewBinder.For(view, vm).
                Action(view.Save, "Click", p => vm.Save(), p=>vm.IsSaveEnabled);

            var binder = viewBinder.GetBinders<IMethodBinder>("Save").First();
            Assert.IsNotNull(binder);
        }
        public void When_adding_an_action_then_method_binder_is_created()
        {
            var vm = new OrderViewModel();
            var view = new OrderView();
            var viewBinder = ViewBinder.For(view, vm)
                .Action(p => vm.Save());

            var binder = viewBinder.GetBinders<IMethodBinder>("Save").First();
            Assert.IsNotNull(binder);
        }
        public void When_adding_a_list_then_list_binder_is_created()
        {
            var vm = new OrderViewModel();
            vm.Customers.Add("Jeff Handley");
            var view = new OrderView();
            var viewBinder = ViewBinder.For(view, vm).
                List(p => vm.Customers);

            var binder = viewBinder.GetBinders<ListBinder<string, OrderViewModel>>("Customers").First();
            Assert.IsNotNull(binder);
        }
        public void When_adding_a_list_and_passing_the_listBox_and_selected_items_then_list_binder_is_created()
        {
            var vm = new OrderViewModel();
            vm.Categories.Add("Category1");
            var view = new OrderView();
            var viewBinder = ViewBinder.For(view, vm).
                List(view.Categories, p => vm.Categories, p => vm.SelectedCategories);

            var binder = viewBinder.GetBinders<ListBinder<string, OrderViewModel>>("Categories").First();
            Assert.IsNotNull(binder);
        }
 public void When_constructed_with_an_expression_then_binds_to_control()
 {
     var vm = new OrderViewModel();
     var view = new OrderView();
     var binder = new MethodBinder(p => vm.Save(),view, vm);
     Assert.AreEqual(view.Save, binder.ViewElement);
 }
        public void When_adding_a_value_then_value_binder_is_created()
        {
            var vm = new OrderViewModel {FirstName = "Jeff"};
            var view = new OrderView();
            var viewBinder = ViewBinder.For(view, vm).
                Value(p => p.FirstName);

            var binder = viewBinder.GetBinders<IValueBinder>("FirstName").First();
            Assert.IsNotNull(binder);
        }
 public void When_constructed_with_an_expression_then_selected_item_binder_is_bound_to_selected_item_property()
 {
     var view = new OrderView();
     var vm = new OrderViewModel();
     var binder = new ListBinder<string, OrderViewModel>(p => p.Customers, view, vm);
     Assert.AreEqual(binder.SelectedItemBinder.Property, ListBox.SelectedItemProperty);
 }
 public void When_constructed_with_an_expression_then_binds_to_vm_is_enabled_action()
 {
     var vm = new OrderViewModel();
     var view = new OrderView();
     var binder = new MethodBinder(p => vm.Save(), view,vm);
     Assert.AreEqual("IsSaveEnabled", binder.IsEnabledBinder.TargetPath);
 }
 public void When_create_is_invoked_then_binder_is_created()
 {
     var definition = new ValueBinderDefinition<OrderViewModel>(p => p.FirstName);
     var vm = new OrderViewModel();
     var view = new OrderView();
     var binder = definition.Create(view, vm);
     Assert.IsNotNull(binder);
 }
 public void When_constructed_with_an_expression_then_binds_to_vm_action()
 {
     var vm = new OrderViewModel();
     var view = new OrderView();
     var binder = new MethodBinder(p => vm.Save(), view,vm);
     Assert.AreEqual("Save", binder.ActionName);
 }