public void can_attach_itself_to_an_element_using_a_mouse_gesture() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Control, MouseAction = MouseAction.LeftDoubleClick, Message = _message }; _node.Expect(x => x.UIElement).Return(_element); trigger.Attach(_node); Assert.That(trigger.Node, Is.EqualTo(_node)); Assert.That(_message.InvalidatedHandler, Is.Not.Null); Assert.That(_message.InitializeCalledWith, Is.EqualTo(_node)); var binding = _element.InputBindings[0]; var gesture = binding.Gesture as MouseGesture; Assert.That(binding.Command, Is.EqualTo(new GestureMessageTrigger.GestureCommand(binding.Gesture))); Assert.That(gesture.MouseAction, Is.EqualTo(MouseAction.LeftDoubleClick)); Assert.That(gesture.Modifiers, Is.EqualTo(ModifierKeys.Control)); }
public void can_attach_itself_to_an_element_using_a_key_gesture() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = _message }; _node.Expect(x => x.UIElement).Return(_element); trigger.Attach(_node); Assert.That(trigger.Node, Is.EqualTo(_node)); Assert.That(_message.InvalidatedHandler, Is.Not.Null); Assert.That(_message.InitializeCalledWith, Is.EqualTo(_node)); var binding = _element.InputBindings[0]; var gesture = binding.Gesture as UnrestrictedKeyGesture; Assert.That(binding.Command, Is.EqualTo(new GestureMessageTrigger.GestureCommand(binding.Gesture))); Assert.That(gesture.Key, Is.EqualTo(Key.S)); Assert.That(gesture.Modifiers, Is.EqualTo(ModifierKeys.Alt)); }
public void can_attach_itself_to_an_element_using_a_key_gesture() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = message }; node.Expect(x => x.UIElement).Return(element); trigger.Attach(node); trigger.Node.ShouldBe(node); message.InvalidatedHandler.ShouldNotBeNull(); message.InitializeCalledWith.ShouldBe(node); var binding = element.InputBindings[0]; var gesture = binding.Gesture as UnrestrictedKeyGesture; binding.Command.ShouldBe(new GestureMessageTrigger.GestureCommand(binding.Gesture)); gesture.Key.ShouldBe(Key.S); gesture.Modifiers.ShouldBe(ModifierKeys.Alt); }
public void can_attach_itself_to_an_element_using_a_mouse_gesture() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Control, MouseAction = MouseAction.LeftDoubleClick, Message = message }; node.Expect(x => x.UIElement).Return(element); trigger.Attach(node); trigger.Node.ShouldBe(node); message.InvalidatedHandler.ShouldNotBeNull(); message.InitializeCalledWith.ShouldBe(node); var binding = element.InputBindings[0]; var gesture = binding.Gesture as MouseGesture; binding.Command.ShouldBe(new GestureMessageTrigger.GestureCommand(binding.Gesture)); gesture.MouseAction.ShouldBe(MouseAction.LeftDoubleClick); gesture.Modifiers.ShouldBe(ModifierKeys.Control); }
public void throws_exception_if_attempt_to_attach_to_non_UIElement() { Assert.Throws <CaliburnException>(() => { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = message }; node.Expect(x => x.UIElement).Return(new DependencyObject()).Repeat.Twice(); trigger.Attach(node); }); }
public void can_update_availability() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = message }; node.Expect(x => x.UIElement).Return(element); node.Expect(x => x.UIElement).Return(element); message.AvailabilityEffect.Expect(x => x.ApplyTo(element, false)); trigger.Attach(node); trigger.UpdateAvailabilty(false); }
public void can_trigger_message_processing() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = message }; object parameter = new object(); node.Expect(x => x.UIElement).Return(element); node.Expect(x => x.ProcessMessage(Arg <IRoutedMessage> .Is.Equal(message), Arg <object> .Is.Equal(parameter))); trigger.Attach(node); element.InputBindings[0].Command.Execute(parameter); }
public void represents_availability_consistently_through_ICommand_for_non_disable_availability_when_available() { message = new FakeMessage { AvailabilityEffect = AvailabilityEffect.Hide }; var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = message }; node.Expect(x => x.UIElement).Return(element); node.Expect(x => x.UIElement).Return(element); trigger.Attach(node); trigger.UpdateAvailabilty(true); element.IsEnabled.ShouldBeTrue(); }
public void throws_exception_if_attempt_to_attach_to_non_UIElement() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = _message }; _node.Expect(x => x.UIElement).Return(new DependencyObject()).Repeat.Twice(); trigger.Attach(_node); }
public void represents_availability_consistently_through_ICommand_for_non_disable_availability_when_available() { _message = new FakeMessage {AvailabilityEffect = AvailabilityEffect.Hide}; var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = _message }; _node.Expect(x => x.UIElement).Return(_element); _node.Expect(x => x.UIElement).Return(_element); trigger.Attach(_node); trigger.UpdateAvailabilty(true); Assert.That(_element.IsEnabled); }
public void can_update_availability() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = _message }; _node.Expect(x => x.UIElement).Return(_element); _node.Expect(x => x.UIElement).Return(_element); _message.AvailabilityEffect.Expect(x => x.ApplyTo(_element, false)); trigger.Attach(_node); trigger.UpdateAvailabilty(false); }
public void can_trigger_message_processing() { var trigger = new GestureMessageTrigger { Modifiers = ModifierKeys.Alt, Key = Key.S, Message = _message }; object parameter = new object(); _node.Expect(x => x.UIElement).Return(_element); _node.Expect(x => x.ProcessMessage(Arg<IRoutedMessage>.Is.Equal(_message), Arg<object>.Is.Equal(parameter))); trigger.Attach(_node); _element.InputBindings[0].Command.Execute(parameter); }