Ejemplo n.º 1
0
        public void Can_add_dynamic_property_to_object_in_viewmodel()
        {
            dynamic viewmodel = new DynamicViewModel();
            viewmodel.Customer = new Customer { Id = 1 };
            viewmodel.Add(DynamicProperty.For<Customer>("Url", c => "/customer/" + c.Id));

            Assert.Equal("/customer/1", viewmodel.Customer.Url);
        }
Ejemplo n.º 2
0
 public void Can_create_with_existing_viewdata()
 {
     var viewData = new ViewDataDictionary();
     dynamic viewmodel = new DynamicViewModel(viewData);
     viewmodel.Test = 1;
     Assert.True(viewData["Test"] is IWrapper);
     dynamic test = viewData["Test"];
     Assert.Equal(1, test);
 }
Ejemplo n.º 3
0
 public void Can_implicitly_cast_to_ViewDataDictionary()
 {
     dynamic viewmodel = new DynamicViewModel();
     viewmodel.Test = 1;
     ViewDataDictionary viewData = viewmodel;
     Assert.True(viewData["Test"] is IWrapper);
     dynamic test = viewData["Test"];
     Assert.Equal(1, test);
 }
Ejemplo n.º 4
0
 public void Can_set_property()
 {
     dynamic viewmodel = new DynamicViewModel();
     viewmodel.Test = 1;
     Assert.Equal(1, viewmodel.Test);
 }
Ejemplo n.º 5
0
 public void Property_returns_wrapper_object()
 {
     dynamic viewmodel = new DynamicViewModel();
     viewmodel.Test = 1;
     Assert.True(viewmodel.Test is IWrapper);
 }