public void AssignOperators() { var vm = new CommandTests_b() { IntProp = 0 }; var bt = BindingTestHelper.BindAssert <Button>( "Button", "Command", @"{b:DXCommand Execute='IntProp = IntProp + 1; IntProp = IntProp + 1;;'}", null, vm); Assert.AreEqual(0, vm.IntProp); BindingTestHelper.DoCommand(bt); BindingTestHelper.DoEvents(bt); Assert.AreEqual(2, vm.IntProp); }
public void T684511() { var vm = new CommandTests_b(); var bt = BindingTestHelper.BindAssert <Button>( "Button", "Command", @"{b:DXCommand Execute='DoException()'}", null, vm); Assert.DoesNotThrow(() => BindingTestHelper.DoCommand(bt)); bt = BindingTestHelper.BindAssert <Button>( "Button", "Command", @"{b:DXCommand Execute='DoException()', CatchExceptions=False}", null, vm); var e = Assert.Throws <TargetInvocationException>(() => BindingTestHelper.DoCommand(bt)); Assert.AreEqual("DoException", e.InnerException.Message); }
public void AssignOperator() { var vm = new CommandTests_b() { IntProp = 0 }; var bt = BindingTestHelper.BindAssert <Button>( "Button", "Command", @"{b:DXCommand Execute='IntProp = IntProp + 1'}", null, vm); Assert.AreEqual(0, vm.IntProp); BindingTestHelper.DoCommand(bt); BindingTestHelper.DoEvents(bt); Assert.AreEqual(1, vm.IntProp); vm.IntProp = 0; bt = BindingTestHelper.BindAssert <Button>( "Button", "Command", @"{b:DXCommand Execute='IntProp = IntProp + @parameter'}", null, vm); bt.CommandParameter = 1; Assert.AreEqual(0, vm.IntProp); BindingTestHelper.DoCommand(bt); BindingTestHelper.DoEvents(bt); Assert.AreEqual(1, vm.IntProp); bt.CommandParameter = 2; BindingTestHelper.DoCommand(bt); BindingTestHelper.DoEvents(bt); Assert.AreEqual(3, vm.IntProp); bt = BindingTestHelper.BindAssert <Button>( "Button", "Command", @"{b:DXCommand Execute='@s.Tag = @parameter'}", null, null); bt.CommandParameter = 1; BindingTestHelper.DoCommand(bt); BindingTestHelper.DoEvents(bt); Assert.AreEqual(1, bt.Tag); bt.CommandParameter = 2; BindingTestHelper.DoCommand(bt); BindingTestHelper.DoEvents(bt); Assert.AreEqual(2, bt.Tag); }
public void NewOperator() { var vm = new CommandTests_b(); var bt = BindingTestHelper.BindAssert <Button>( "Button", "Command", @"{b:DXCommand Execute='Do(@s.Margin);', CanExecute='new $Thickness(@s.Margin.Bottom).Left == 1'}", null, vm); Assert.AreEqual(false, BindingTestHelper.CanDoCommand(bt)); Assert.AreEqual(0, vm.DoubleProp); bt.Margin = new Thickness(1, 0, 0, 0); BindingTestHelper.DoEvents(bt); Assert.AreEqual(false, BindingTestHelper.CanDoCommand(bt)); Assert.AreEqual(0, vm.DoubleProp); bt.Margin = new Thickness(1, 0, 0, 1); BindingTestHelper.DoEvents(bt); Assert.AreEqual(true, BindingTestHelper.CanDoCommand(bt)); BindingTestHelper.DoCommand(bt); BindingTestHelper.DoEvents(bt); Assert.AreEqual(1, vm.DoubleProp); }