Пример #1
0
        public void EnablingChangesIsEnabledToTrue()
        {
            var registrationControllerMock = MockRepository.GenerateMock<IHotKeyRegistrationController>();
            registrationControllerMock.Stub(x => x.Register(Arg<IHotKey>.Is.Anything)).Return(0);
            var hotKey = new HotKey(registrationControllerMock);
            hotKey.Key = System.Windows.Forms.Keys.A;

            Assert.IsFalse(hotKey.IsEnabled);
            hotKey.Enable();
            Assert.IsTrue(hotKey.IsEnabled);
        }
Пример #2
0
        public void IdIsSetToControllerProvidedValueWhenHotKeyIsEnabled()
        {
            var id = 15;
            var registrationControllerMock = MockRepository.GenerateMock<IHotKeyRegistrationController>();
            registrationControllerMock.Stub(x => x.Register(Arg<IHotKey>.Is.Anything)).Return(id);
            var hotKey = new HotKey(registrationControllerMock);
            hotKey.Key = System.Windows.Forms.Keys.A;

            Assert.AreNotEqual(id, hotKey.Id);
            hotKey.Enable();
            Assert.AreEqual(id, hotKey.Id);
        }
Пример #3
0
 public void EnablingHotKeyWithoutKeySetThrowsException()
 {
     var registrationControllerMock = MockRepository.GenerateMock<IHotKeyRegistrationController>();
     var hotKey = new HotKey(registrationControllerMock);
     Assert.Throws<ArgumentException>(() => hotKey.Enable());
 }
Пример #4
0
 public void DisablingWhileDisabledSucceeds()
 {
     var registrationControllerMock = MockRepository.GenerateMock<IHotKeyRegistrationController>();
     var hotKey = new HotKey( registrationControllerMock);
     Assert.DoesNotThrow(() => hotKey.Disable());
 }
Пример #5
0
        public void ToStringOutputsModifierAndKeyNameWhenOneModifierIsSet()
        {
            var hotKey = new HotKey(null);
            hotKey.Modifiers = ModifierKeys.Control;
            hotKey.Key = System.Windows.Forms.Keys.A;
            var stringValue = hotKey.ToString();

            Assert.AreEqual("Control + A", stringValue);
        }
Пример #6
0
        public void ToStringOutputsKeyNameOnlyWhenModifierNoneIsSet()
        {
            var hotKey = new HotKey(null);
            hotKey.Modifiers = ModifierKeys.None;
            hotKey.Key = System.Windows.Forms.Keys.None;
            var stringValue = hotKey.ToString();

            Assert.AreEqual("None", stringValue);
        }
Пример #7
0
        public void ToStringOutputsAllSetModifiersAndKeyNameWhenMultipleModifiersAreSet()
        {
            var hotKey = new HotKey(null);
            hotKey.Modifiers = ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Windows;
            hotKey.Key = System.Windows.Forms.Keys.A;
            var stringValue = hotKey.ToString();

            Assert.AreEqual("Control + Shift + Windows + A", stringValue);
        }