Ejemplo n.º 1
0
 public void BasicBindingTest()
 {
     // Use Set to copy String1 to String2 using the DataContext of a Window.
     var viewModel = new BasicViewModel { String1 = "Test" };
     Assert.Equal("Test", viewModel.String1);
     Assert.Equal(null, viewModel.String2);
     TestHelper.AttachAndExecute(new Window { DataContext = viewModel },
         TestHelper.Configure(new Set { PropertyName = "String2" },
             TestHelper.TargetBinder,
             value => BindingOperations.SetBinding(value, Set.ValueProperty, new Binding("String1"))));
     Assert.Equal("Test", viewModel.String1);
     Assert.Equal("Test", viewModel.String2);
 }
 public void BreakTest()
 {
     // Create a infinite loop containing a break preceded by an statement and followed
     // an statement and check that only the former is executed.
     var viewModel = new BasicViewModel();
     Assert.Equal(null, viewModel.String1);
     Assert.Equal(null, viewModel.String2);
     TestHelper.AttachAndExecute(new Window { DataContext = viewModel },
         new While
         {
             Body =
             {
                 TestHelper.Configure(new Set { PropertyName = "String1", Value = "Test1" },
                     TestHelper.TargetBinder),
                 new Break(),
                 TestHelper.Configure(new Set { PropertyName = "String2", Value = "Test2" },
                     TestHelper.TargetBinder),
             }
         });
     Assert.Equal("Test1", viewModel.String1);
     Assert.Equal(null, viewModel.String2);
 }