public ReSharperActionShortcutProvider(ShortcutDisplayStatistics statistics,
                                        IActionDefs defs,
                                        IActionShortcuts actionShortcuts,
                                        ActionPresentationHelper actionPresentationHelper,
                                        OverriddenShortcutFinder overriddenShortcutFinder,
                                        HotspotSessionExecutor hotspotSessionExecutor,
                                        SettingsStore settingsStore)
 {
     this.statistics               = statistics;
     this.defs                     = defs;
     this.actionShortcuts          = actionShortcuts;
     this.actionPresentationHelper = actionPresentationHelper;
     this.overriddenShortcutFinder = overriddenShortcutFinder;
     this.hotspotSessionExecutor   = hotspotSessionExecutor;
     this.settingsStore            = settingsStore;
 }
Ejemplo n.º 2
0
        private Mock <IActionManager> SetUpActionManager()
        {
            var am = Mock.Of <IActionManager>();
            var mockActionManager = Mock.Get(am);

            _actionDefs     = Mock.Of <IActionDefs>();
            _actionHandlers = Mock.Of <IActionHandlers>();

            mockActionManager.Setup(m => m.Defs).Returns(_actionDefs);
            mockActionManager.Setup(m => m.Handlers).Returns(_actionHandlers);

            Dictionary <IActionDefWithId, IAction> registeredHandlers = new Dictionary <IActionDefWithId, IAction>();

            // store new handlers in handlers dictionary together with their actions
            Mock.Get(_actionHandlers)
            .Setup(ah => ah.AddHandler(It.IsAny <IActionDefWithId>(), It.IsAny <IAction>()))
            .Callback <IActionDefWithId, IAction>(
                (id, action) => { registeredHandlers.Add(id, action); });

            // mock the execution of registered actions
            Mock.Get(_actionHandlers)
            .Setup(ah => ah.Evaluate(It.IsAny <IActionDefWithId>(), It.IsAny <IDataContext>()))
            .Callback <IActionDefWithId, IDataContext>(
                (id, context) =>
            {
                var action    = registeredHandlers[id];
                var delAction = action as KaVEDelegateActionHandler;
                if (delAction != null)
                {
                    delAction.Execute(context, () => { });
                }
            });

            SetupExecutableAction(am, _actionDefs, ForceCompleteActionId);
            SetupExecutableAction(am, _actionDefs, EnterActionId);
            SetupExecutableAction(am, _actionDefs, TabActionId);

            return(mockActionManager);
        }
Ejemplo n.º 3
0
        public void SetupExecutableAction(IActionManager manager, IActionDefs defs, string actionId)
        {
            var actionDef = Mock.Of <IActionDefWithId>();

            Mock.Get(defs).Setup(d => d.GetActionDefById(actionId)).Returns(actionDef);
        }