public Hotkey Create(HotkeySetting setting, IntPtr hWndVbe) { if (setting == null) { return(null); } var commandToBind = _commands.FirstOrDefault(command => command.GetType().Name == setting.CommandTypeName); return(commandToBind == null ? null : new Hotkey(hWndVbe, setting.ToString(), commandToBind)); }
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); }); }