public void CreatingHotkeyReturnsNullWhenNoSettingProvided() { var factory = new HotkeyFactory(null); var hotkey = factory.Create(null, IntPtr.Zero); Assert.IsNull(hotkey); }
public void CreatingHotkeyReturnsNullWhenNoMatchingCommandExists() { var mockCommand = new Mock <CommandBase>(null).Object; var factory = new HotkeyFactory(new[] { mockCommand }); var setting = new HotkeySetting { CommandTypeName = "Foo" }; var hotkey = factory.Create(setting, IntPtr.Zero); Assert.IsNull(hotkey); }
public void CreatingHotkeyReturnsCorrectResult() { var mockCommand = new Mock <CommandBase>(null).Object; var factory = new HotkeyFactory(new[] { mockCommand }); var setting = new HotkeySetting { CommandTypeName = mockCommand.GetType().Name, Key1 = "X", HasCtrlModifier = true }; var hotkey = factory.Create(setting, IntPtr.Zero); Assert.Multiple(() => { Assert.AreEqual(mockCommand, hotkey.Command); Assert.AreEqual(setting.ToString(), hotkey.Key); }); }
public void HookHotkeys() { Detach(); _hooks.Clear(); var config = _config.LoadConfiguration(); var settings = config.UserSettings.HotkeySettings; foreach (var hotkeySetting in settings.Settings.Where(hotkeySetting => hotkeySetting.IsEnabled)) { var hotkey = _hotkeyFactory.Create(hotkeySetting, Hwnd); if (hotkey != null) { AddHook(hotkey); } } Attach(); }