Example #1
0
        private void Create(KeyRemapMode countKeyRemapMode, params string[] lines)
        {
            _textView = CreateTextView(lines);
            _vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer);
            _registerMap = Vim.RegisterMap;
            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView);
            _commandUtil = CreateCommandUtil(vimBufferData);
            var incrementalSearch = new IncrementalSearch(
                vimBufferData,
                CommonOperationsFactory.GetCommonOperations(vimBufferData));
            var motionCapture = new MotionCapture(vimBufferData, incrementalSearch);

            _runnerRaw = new CommandRunner(
                _textView,
                _registerMap,
                motionCapture,
                vimBufferData.LocalSettings,
                _commandUtil,
                new StatusUtil(),
                VisualKind.Character,
                countKeyRemapMode);
            _runner = _runnerRaw;
        }
Example #2
0
 public void Setup()
 {
     _factory = new MockRepository(MockBehavior.Strict);
     _clipboard = MockObjectFactory.CreateClipboardDevice(_factory);
     _rawMap = new RegisterMap(_clipboard.Object);
     _map = _rawMap;
 }
Example #3
0
        private void Create(params string[] lines)
        {
            _textView    = EditorUtil.CreateView(lines);
            _factory     = new MockRepository(MockBehavior.Strict);
            _host        = _factory.Create <IVimHost>();
            _statusUtil  = _factory.Create <IStatusUtil>();
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
            _vimData     = new VimData();
            var settings      = new GlobalSettings();
            var localSettings = new LocalSettings(settings, _textView);
            var motionUtil    = VimUtil.CreateTextViewMotionUtil(
                _textView,
                settings: localSettings,
                vimData: _vimData);
            var capture = new MotionCapture(
                _host.Object,
                _textView,
                MockObjectFactory.CreateIncrementalSearch(factory: _factory).Object,
                localSettings);

            _commandUtil = VimUtil.CreateCommandUtil(
                _textView,
                motionUtil: motionUtil,
                statusUtil: _statusUtil.Object,
                registerMap: _registerMap,
                vimData: _vimData);
            _runnerRaw = new CommandRunner(
                _textView,
                _registerMap,
                capture,
                _commandUtil,
                _statusUtil.Object,
                VisualKind.Character);
            _runner = _runnerRaw;
        }
Example #4
0
        private void Create(KeyRemapMode countKeyRemapMode, params string[] lines)
        {
            _textView      = CreateTextView(lines);
            _vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer);
            _registerMap   = Vim.RegisterMap;
            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView);

            _commandUtil = CreateCommandUtil(vimBufferData);
            var incrementalSearch = new IncrementalSearch(
                vimBufferData,
                CommonOperationsFactory.GetCommonOperations(vimBufferData));
            var motionCapture = new MotionCapture(vimBufferData, incrementalSearch);

            _runnerRaw = new CommandRunner(
                _textView,
                _registerMap,
                motionCapture,
                vimBufferData.LocalSettings,
                _commandUtil,
                new StatusUtil(),
                VisualKind.Character,
                countKeyRemapMode);
            _runner = _runnerRaw;
        }
Example #5
0
        public void Create2(
            ModeKind kind = ModeKind.VisualCharacter,
            params string[] lines)
        {
            _textView   = EditorUtil.CreateView(lines);
            _textBuffer = _textView.TextBuffer;
            _selection  = _textView.Selection;
            _factory    = new MockRepository(MockBehavior.Strict);
            _map        = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
            _markMap    = new MarkMap(new TrackingLineColumnService());
            _tracker    = _factory.Create <ISelectionTracker>();
            _tracker.Setup(x => x.Start());
            _tracker.Setup(x => x.ResetCaret());
            _tracker.Setup(x => x.UpdateSelection());
            _jumpList           = _factory.Create <IJumpList>(MockBehavior.Loose);
            _undoRedoOperations = _factory.Create <IUndoRedoOperations>();
            _foldManager        = _factory.Create <IFoldManager>();
            _editorOperations   = _factory.Create <IEditorOperations>();
            _operations         = _factory.Create <ICommonOperations>();
            _operations.SetupGet(x => x.FoldManager).Returns(_foldManager.Object);
            _operations.SetupGet(x => x.UndoRedoOperations).Returns(_undoRedoOperations.Object);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_textView);
            _host        = _factory.Create <IVimHost>(MockBehavior.Loose);
            _commandUtil = _factory.Create <ICommandUtil>();
            _commandUtil
            .Setup(x => x.RunCommand(It.Is <Command>(y => y.IsLegacyCommand)))
            .Returns <Command>(c => c.AsLegacyCommand().Item.Function.Invoke(null));
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            var globalSettings = new GlobalSettings();
            var localSettings  = new LocalSettings(globalSettings, _textView);
            var motionUtil     = VimUtil.CreateTextViewMotionUtil(
                _textView,
                _markMap,
                localSettings);

            _bufferData = MockObjectFactory.CreateVimBuffer(
                _textView,
                "test",
                MockObjectFactory.CreateVim(_map, host: _host.Object, settings: globalSettings).Object,
                incrementalSearch: _incrementalSearch.Object,
                jumpList: _jumpList.Object,
                motionUtil: motionUtil);
            var capture = new MotionCapture(
                _host.Object,
                _textView,
                _incrementalSearch.Object,
                localSettings);
            var runner = new CommandRunner(
                _textView,
                _map,
                capture,
                _commandUtil.Object,
                (new Mock <IStatusUtil>()).Object,
                VisualKind.Character);

            _modeRaw = new VisualMode(_bufferData.Object, _operations.Object, kind, runner, capture, _tracker.Object);
            _mode    = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
Example #6
0
 protected RegisterMapTest()
 {
     _factory = new MockRepository(MockBehavior.Strict);
     _clipboard = MockObjectFactory.CreateClipboardDevice(_factory);
     _fileName = null;
     _rawMap = VimUtil.CreateRegisterMap(_clipboard.Object, () => _fileName);
     _map = _rawMap;
 }
 protected RegisterMapTest()
 {
     _factory   = new MockRepository(MockBehavior.Strict);
     _clipboard = MockObjectFactory.CreateClipboardDevice(_factory);
     _fileName  = null;
     _rawMap    = VimUtil.CreateRegisterMap(_clipboard.Object, () => _fileName);
     _map       = _rawMap;
 }
Example #8
0
        public void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateTextView(lines);
            _vimData = new VimData();
            _editorOptions = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(_textView);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _textBuffer = _textView.TextBuffer;
            _factory = new MockRepository(MockBehavior.Strict);
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
            _host = _factory.Create<IVimHost>();
            _jumpList = _factory.Create<IJumpList>();
            _editorOperations = _factory.Create<IEditorOperations>();
            _editorOperations.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editorOperations.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _globalSettings.SetupGet(x => x.IsVirtualEditOneMore).Returns(false);
            _globalSettings.SetupGet(x => x.UseEditorIndent).Returns(false);
            _globalSettings.SetupGet(x => x.UseEditorSettings).Returns(false);
            _globalSettings.SetupGet(x => x.VirtualEdit).Returns(String.Empty);
            _globalSettings.SetupGet(x => x.WrapScan).Returns(true);
            _settings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object, _factory);
            _settings.SetupGet(x => x.AutoIndent).Returns(false);
            _settings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
            _settings.SetupGet(x => x.ExpandTab).Returns(true);
            _settings.SetupGet(x => x.TabStop).Returns(4);
            _outlining = _factory.Create<IOutliningManager>();
            _outlining
                .Setup(x => x.ExpandAll(It.IsAny<SnapshotSpan>(), It.IsAny<Predicate<ICollapsed>>()))
                .Returns<IEnumerable<ICollapsible>>(null);
            _globalSettings.SetupGet(x => x.ShiftWidth).Returns(2);
            _statusUtil = _factory.Create<IStatusUtil>();
            _searchService = VimUtil.CreateSearchService(_globalSettings.Object);
            _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object);

            var data = new OperationsData(
                vimData: _vimData,
                vimHost: _host.Object,
                editorOperations: _editorOperations.Object,
                textView: _textView,
                outliningManager: FSharpOption.Create(_outlining.Object),
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                undoRedoOperations: _undoRedoOperations,
                registerMap: _registerMap,
                editorOptions: _editorOptions,
                keyMap: null,
                statusUtil: _statusUtil.Object,
                foldManager: null,
                searchService: _searchService,
                wordUtil: VimUtil.GetWordUtil(_textView));

            _operationsRaw = new CommonOperations(data);
            _operations = _operationsRaw;
        }
Example #9
0
            public ReplaceTest()
            {
                _clipboardDevice = new Mock <IClipboardDevice>(MockBehavior.Loose);
                Func <FSharpOption <string> > func = () => FSharpOption <string> .None;

                _registerMap = new RegisterMap(
                    new VimData(_globalSettings),
                    _clipboardDevice.Object,
                    func.ToFSharpFunc());
            }
Example #10
0
        internal static CommandUtil CreateCommandUtil(
            ITextView textView,
            ICommonOperations operations                     = null,
            IMotionUtil motionUtil                           = null,
            IStatusUtil statusUtil                           = null,
            IRegisterMap registerMap                         = null,
            IMarkMap markMap                                 = null,
            IVimData vimData                                 = null,
            IVimLocalSettings localSettings                  = null,
            IUndoRedoOperations undoRedOperations            = null,
            ISmartIndentationService smartIndentationService = null,
            IFoldManager foldManager                         = null,
            IVimHost vimHost                                 = null,
            IMacroRecorder recorder                          = null,
            ISearchService searchService                     = null,
            ITextStructureNavigator wordNavigator            = null,
            IJumpList jumpList                               = null)
        {
            statusUtil              = statusUtil ?? new StatusUtil();
            undoRedOperations       = undoRedOperations ?? VimUtil.CreateUndoRedoOperations(statusUtil);
            localSettings           = localSettings ?? new LocalSettings(new GlobalSettings());
            registerMap             = registerMap ?? CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            markMap                 = markMap ?? new MarkMap(new TrackingLineColumnService());
            vimData                 = vimData ?? new VimData();
            motionUtil              = motionUtil ?? CreateTextViewMotionUtil(textView, markMap: markMap, vimData: vimData, settings: localSettings);
            operations              = operations ?? CreateCommonOperations(textView, localSettings, vimData: vimData, statusUtil: statusUtil);
            smartIndentationService = smartIndentationService ?? CreateSmartIndentationService();
            foldManager             = foldManager ?? CreateFoldManager(textView.TextBuffer);
            searchService           = searchService ?? CreateSearchService(localSettings.GlobalSettings);
            wordNavigator           = wordNavigator ?? CreateTextStructureNavigator(textView.TextBuffer, WordKind.NormalWord);
            jumpList                = jumpList ?? CreateJumpList();
            vimHost                 = vimHost ?? new MockVimHost();
            var vim = MockObjectFactory.CreateVim(
                registerMap: registerMap,
                map: markMap,
                host: vimHost,
                vimData: vimData,
                recorder: recorder,
                searchService: searchService);
            var buffer = MockObjectFactory.CreateVimBuffer(
                textView: textView,
                settings: localSettings,
                motionUtil: motionUtil,
                vim: vim.Object,
                wordNavigator: wordNavigator,
                jumpList: jumpList);

            return(new CommandUtil(
                       buffer.Object,
                       operations,
                       statusUtil,
                       undoRedOperations,
                       smartIndentationService,
                       foldManager));
        }
Example #11
0
 public void Create(params string[] lines)
 {
     _view = Utils.EditorUtil.CreateView(lines);
     _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
     _map = new RegisterMap();
     _host = new FakeVimHost();
     _editOpts = new Mock<IEditorOperations>(MockBehavior.Strict);
     _operations = new Mock<IOperations>(MockBehavior.Strict);
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _view,
         "test",
         MockObjectFactory.CreateVim(_map, host: _host).Object,
         _editOpts.Object);
     _processorRaw = new Vim.Modes.Command.CommandProcessor(_bufferData.Object, _operations.Object);
     _processor = _processorRaw;
 }
        public void Create(params string[] lines)
        {
            _context = new TestableSynchronizationContext();
            SynchronizationContext.SetSynchronizationContext(_context);
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
            _vimTextBuffer = _vimBuffer.VimTextBuffer;
            _registerMap = _vimBuffer.RegisterMap;
            _globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
            Assert.IsTrue(_context.IsEmpty);

            // Need to make sure it's focused so macro recording will work
            ((MockVimHost)_vimBuffer.Vim.VimHost).FocusedTextView = _textView;
        }
 public void Create(params string[] lines)
 {
     _view = Utils.EditorUtil.CreateView(lines);
     _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
     _map = new RegisterMap();
     _editOpts = new Mock<IEditorOperations>(MockBehavior.Strict);
     _operations = new Mock<IOperations>(MockBehavior.Strict);
     _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
     _statusUtil = new Mock<IStatusUtil>();
     _fileSystem = new Mock<IFileSystem>(MockBehavior.Strict);
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _view,
         "test",
         MockObjectFactory.CreateVim(_map).Object);
     _processorRaw = new Vim.Modes.Command.CommandProcessor(_bufferData.Object, _operations.Object, _statusUtil.Object, _fileSystem.Object);
     _processor = _processorRaw;
 }
Example #14
0
 public void Create(params string[] lines)
 {
     _view = EditorUtil.CreateView(lines);
     _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
     _factory = new MockRepository(MockBehavior.Strict);
     _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _editOpts = _factory.Create<IEditorOperations>();
     _vimHost = _factory.Create<IVimHost>();
     _operations = _factory.Create<IOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
     _statusUtil = _factory.Create<IStatusUtil>();
     _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _view,
         "test",
         MockObjectFactory.CreateVim(_map, host: _vimHost.Object).Object);
     _processorRaw = new Vim.Modes.Command.CommandProcessor(_bufferData.Object, _operations.Object, _statusUtil.Object, _fileSystem.Object);
     _processor = _processorRaw;
 }
Example #15
0
        public static Mock <IVim> CreateVim(
            IRegisterMap registerMap          = null,
            IMarkMap map                      = null,
            IVimGlobalSettings globalSettings = null,
            IVimGlobalAbbreviationMap globalAbbreviationMap = null,
            IVimGlobalKeyMap globalKeyMap = null,
            IVimHost host = null,
            IKeyboardDevice keyboardDevice = null,
            IMouseDevice mouseDevice       = null,
            IVimData vimData             = null,
            IMacroRecorder macroRecorder = null,
            ISearchService searchService = null,
            Dictionary <string, VariableValue> variableMap = null,
            MockRepository factory = null)
        {
            factory               = factory ?? new MockRepository(MockBehavior.Strict);
            registerMap           = registerMap ?? CreateRegisterMap().Object;
            map                   = map ?? new MarkMap(new BufferTrackingService());
            globalSettings        = globalSettings ?? new GlobalSettings();
            host                  = host ?? new MockVimHost();
            variableMap           = variableMap ?? new Dictionary <string, VariableValue>();
            globalKeyMap          = globalKeyMap ?? new GlobalKeyMap(variableMap);
            macroRecorder         = macroRecorder ?? CreateMacroRecorder(factory: factory).Object;
            searchService         = searchService ?? factory.Create <ISearchService>().Object;
            keyboardDevice        = keyboardDevice ?? (factory.Create <IKeyboardDevice>(MockBehavior.Loose)).Object;
            mouseDevice           = mouseDevice ?? (factory.Create <IMouseDevice>(MockBehavior.Loose)).Object;
            vimData               = vimData ?? VimUtil.CreateVimData();
            globalAbbreviationMap = globalAbbreviationMap ?? new GlobalAbbreviationMap();
            var mock = factory.Create <IVim>(MockBehavior.Strict);

            mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
            mock.SetupGet(x => x.MarkMap).Returns(map);
            mock.SetupGet(x => x.GlobalSettings).Returns(globalSettings);
            mock.SetupGet(x => x.GlobalAbbreviationMap).Returns(globalAbbreviationMap);
            mock.SetupGet(x => x.GlobalKeyMap).Returns(globalKeyMap);
            mock.SetupGet(x => x.VimHost).Returns(host);
            mock.SetupGet(x => x.VimData).Returns(vimData);
            mock.SetupGet(x => x.MacroRecorder).Returns(macroRecorder);
            mock.SetupGet(x => x.SearchService).Returns(searchService);
            mock.SetupGet(x => x.VariableMap).Returns(variableMap);
            return(mock);
        }
Example #16
0
        public void Create(params string[] lines)
        {
            _context = new TestableSynchronizationContext();
            SynchronizationContext.SetSynchronizationContext(_context);
            var tuple = EditorUtil.CreateTextViewAndEditorOperations(lines);

            _textView   = tuple.Item1;
            _textBuffer = _textView.TextBuffer;
            var service = EditorUtil.FactoryService;

            _buffer = service.Vim.CreateVimBuffer(_textView);
            _buffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
            _vimTextBuffer  = _buffer.VimTextBuffer;
            _registerMap    = _buffer.RegisterMap;
            _globalSettings = _buffer.LocalSettings.GlobalSettings;
            Assert.IsTrue(_context.IsEmpty);

            // Need to make sure it's focused so macro recording will work
            ((MockVimHost)_buffer.Vim.VimHost).FocusedTextView = _textView;
        }
Example #17
0
        private void Create(params string[] lines)
        {
            _textView      = CreateTextView(lines);
            _vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer);
            _registerMap   = Vim.RegisterMap;
            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView);

            _commandUtil = VimUtil.CreateCommandUtil(vimBufferData);
            var motionCapture = VimUtil.CreateMotionCapture(vimBufferData);

            _runnerRaw = new CommandRunner(
                _textView,
                _registerMap,
                motionCapture,
                _commandUtil,
                new StatusUtil(),
                VisualKind.Character);
            _runner = _runnerRaw;
        }
Example #18
0
 public static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     IMarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IKeyboardDevice keyboardDevice = null,
     IMouseDevice mouseDevice = null,
     IVimData vimData = null,
     IMacroRecorder macroRecorder = null,
     ISearchService searchService = null,
     Dictionary<string, VariableValue> variableMap = null,
     MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new BufferTrackingService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new MockVimHost();
     keyMap = keyMap ?? (new KeyMap(settings, new Dictionary<string, VariableValue>()));
     macroRecorder = macroRecorder ?? CreateMacroRecorder(factory: factory).Object;
     searchService = searchService ?? factory.Create<ISearchService>().Object;
     keyboardDevice = keyboardDevice ?? (factory.Create<IKeyboardDevice>(MockBehavior.Loose)).Object;
     mouseDevice = mouseDevice ?? (factory.Create<IMouseDevice>(MockBehavior.Loose)).Object;
     vimData = vimData ?? VimUtil.CreateVimData();
     variableMap = variableMap ?? new Dictionary<string, VariableValue>();
     var mock = factory.Create<IVim>(MockBehavior.Strict);
     mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
     mock.SetupGet(x => x.MarkMap).Returns(map);
     mock.SetupGet(x => x.GlobalSettings).Returns(settings);
     mock.SetupGet(x => x.VimHost).Returns(host);
     mock.SetupGet(x => x.KeyMap).Returns(keyMap);
     mock.SetupGet(x => x.VimData).Returns(vimData);
     mock.SetupGet(x => x.MacroRecorder).Returns(macroRecorder);
     mock.SetupGet(x => x.SearchService).Returns(searchService);
     mock.SetupGet(x => x.VariableMap).Returns(variableMap);
     return mock;
 }
Example #19
0
        public static Mock <IVim> CreateVim(
            IRegisterMap registerMap       = null,
            IMarkMap map                   = null,
            IVimGlobalSettings settings    = null,
            IVimHost host                  = null,
            IKeyMap keyMap                 = null,
            IKeyboardDevice keyboardDevice = null,
            IMouseDevice mouseDevice       = null,
            IVimData vimData               = null,
            IMacroRecorder recorder        = null,
            ISearchService searchService   = null,
            MockRepository factory         = null)
        {
            factory        = factory ?? new MockRepository(MockBehavior.Strict);
            registerMap    = registerMap ?? CreateRegisterMap().Object;
            map            = map ?? new MarkMap(new TrackingLineColumnService());
            settings       = settings ?? new GlobalSettings();
            host           = host ?? new MockVimHost();
            keyMap         = keyMap ?? (new KeyMap());
            recorder       = recorder ?? CreateMacroRecorder(factory: factory).Object;
            searchService  = searchService ?? factory.Create <ISearchService>().Object;
            keyboardDevice = keyboardDevice ?? (factory.Create <IKeyboardDevice>(MockBehavior.Loose)).Object;
            mouseDevice    = mouseDevice ?? (factory.Create <IMouseDevice>(MockBehavior.Loose)).Object;
            vimData        = vimData ?? new VimData();
            var mock = factory.Create <IVim>(MockBehavior.Strict);

            mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
            mock.SetupGet(x => x.MarkMap).Returns(map);
            mock.SetupGet(x => x.Settings).Returns(settings);
            mock.SetupGet(x => x.VimHost).Returns(host);
            mock.SetupGet(x => x.KeyMap).Returns(keyMap);
            mock.SetupGet(x => x.VimData).Returns(vimData);
            mock.SetupGet(x => x.MacroRecorder).Returns(recorder);
            mock.SetupGet(x => x.SearchService).Returns(searchService);
            return(mock);
        }
Example #20
0
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = EditorUtil.CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _unnamedRegister = _map.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _editorOperations = _factory.Create<IEditorOperations>(MockBehavior.Loose);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _jumpList = _factory.Create<IJumpList>(MockBehavior.Strict);
            _statusUtil = _factory.Create<IStatusUtil>(MockBehavior.Strict);
            _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
            _host = _factory.Create<IVimHost>(MockBehavior.Loose);
            _commandUtil = _factory.Create<ICommandUtil>();
            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _vimData = new VimData();

            _globalSettings = new Vim.GlobalSettings();
            _localSettings = new LocalSettings(_globalSettings, EditorUtil.GetEditorOptions(_textView), _textView);
            motionUtil = motionUtil ?? VimUtil.CreateTextViewMotionUtil(
                _textView,
                new MarkMap(new TrackingLineColumnService()),
                _localSettings);
            _buffer = MockObjectFactory.CreateVimBuffer(
                _textView,
                "test",
                MockObjectFactory.CreateVim(_map, host: _host.Object, vimData: _vimData).Object,
                _jumpList.Object,
                incrementalSearch: _incrementalSearch.Object,
                motionUtil: motionUtil,
                settings: _localSettings);
            _operations = _factory.Create<ICommonOperations>(MockBehavior.Strict);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_textView);

            var capture = new MotionCapture(
                _host.Object,
                _textView,
                _incrementalSearch.Object,
                new LocalSettings(new GlobalSettings(), EditorUtil.GetEditorOptions(_textView), _textView));
            var runner = new CommandRunner(_textView, _map, capture, _commandUtil.Object, _statusUtil.Object, VisualKind.Character);
            _modeRaw = new NormalMode(
                _buffer.Object,
                _operations.Object,
                _statusUtil.Object,
                _displayWindowBroker.Object,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
Example #21
0
        public void CreateCore(ITextViewMotionUtil motionUtil, params string[] lines)
        {
            _view = EditorUtil.CreateView(lines);
            _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
            _map = new RegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _editorOperations = new Mock<IEditorOperations>();
            _incrementalSearch = new Mock<IIncrementalSearch>(MockBehavior.Strict);
            _jumpList = new Mock<IJumpList>(MockBehavior.Strict);
            _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
            _changeTracker = new Mock<IChangeTracker>(MockBehavior.Strict);
            _foldManager = new Mock<IFoldManager>(MockBehavior.Strict);
            _visualSpanCalculator = new Mock<IVisualSpanCalculator>(MockBehavior.Strict);
            _host = new Mock<IVimHost>(MockBehavior.Loose);
            _displayWindowBroker = new Mock<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _bufferData = MockRepository.CreateVimBuffer(
                _view,
                "test",
                MockRepository.CreateVim(_map, changeTracker: _changeTracker.Object, host: _host.Object).Object,
                _jumpList.Object);
            _operations = new Mock<IOperations>(MockBehavior.Strict);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_view);
            _operations.SetupGet(x => x.FoldManager).Returns(_foldManager.Object);

            motionUtil = motionUtil ?? new TextViewMotionUtil(_view, new Vim.LocalSettings(
                    new Vim.GlobalSettings(),
                    _view));
            var capture = new MotionCapture(_host.Object, _view, motionUtil, new MotionCaptureGlobalData());
            var runner = new CommandRunner(_view, _map, (IMotionCapture)capture, _statusUtil.Object);
            _modeRaw = new Vim.Modes.Normal.NormalMode(
                _bufferData.Object,
                _operations.Object,
                _incrementalSearch.Object,
                _statusUtil.Object,
                _displayWindowBroker.Object,
                (ICommandRunner)runner,
                (IMotionCapture)capture,
                _visualSpanCalculator.Object);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
Example #22
0
 private void Create(params string[] lines)
 {
     _statusUtil = new TestableStatusUtil();
     _vimData = Vim.VimData;
     _vimBufferData = CreateVimBufferData(
         CreateTextView(lines),
         statusUtil: _statusUtil);
     _vimBuffer = CreateVimBuffer(_vimBufferData);
     _vimTextBuffer = _vimBufferData.VimTextBuffer;
     _localSettings = _vimBufferData.LocalSettings;
     _globalSettings = _localSettings.GlobalSettings;
     _textBuffer = _vimBufferData.TextBuffer;
     _textView = _vimBufferData.TextView;
     _interpreter = new global::Vim.Interpreter.Interpreter(
         _vimBuffer,
         CommonOperationsFactory.GetCommonOperations(_vimBufferData),
         FoldManagerFactory.GetFoldManager(_vimBufferData.TextView),
         new FileSystem(),
         BufferTrackingService);
     _registerMap = Vim.RegisterMap;
     _keyMap = Vim.KeyMap;
 }
Example #23
0
 public static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     MarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IChangeTracker changeTracker = null,
     IKeyboardDevice keyboardDevice = null,
     IMouseDevice mouseDevice = null)
 {
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new TrackingLineColumnService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new MockVimHost();
     keyMap = keyMap ?? (new KeyMap());
     keyboardDevice = keyboardDevice ?? (new Mock<IKeyboardDevice>(MockBehavior.Loose)).Object;
     mouseDevice = mouseDevice ?? (new Mock<IMouseDevice>(MockBehavior.Loose)).Object;
     changeTracker = changeTracker ?? new ChangeTracker(new TextChangeTrackerFactory(keyboardDevice, mouseDevice));
     var mock = new Mock<IVim>(MockBehavior.Strict);
     mock.Setup(x => x.RegisterMap).Returns(registerMap);
     mock.Setup(x => x.MarkMap).Returns(map);
     mock.Setup(x => x.Settings).Returns(settings);
     mock.Setup(x => x.VimHost).Returns(host);
     mock.Setup(x => x.KeyMap).Returns(keyMap);
     mock.Setup(x => x.ChangeTracker).Returns(changeTracker);
     return mock;
 }
Example #24
0
 private void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _factory = new MockFactory(MockBehavior.Strict);
     _statusUtil = _factory.Create<IStatusUtil>();
     _registerMap = new RegisterMap();
     _runnerRaw = new CommandRunner(Tuple.Create(
         _textView,
         _registerMap,
         _statusUtil.Object));
     _runner = _runnerRaw;
 }
Example #25
0
        private void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateView(lines);
            _textBuffer = _textView.TextBuffer;

            _factory = new MockRepository(MockBehavior.Loose);
            _vimHost = _factory.Create<IVimHost>();
            _statusUtil = _factory.Create<IStatusUtil>();
            _operations = _factory.Create<ICommonOperations>();
            _operations.Setup(x => x.EnsureCaretOnScreenAndTextExpanded());
            _operations.Setup(x => x.RaiseSearchResultMessages(It.IsAny<SearchResult>()));
            _operations.Setup(x => x.EditorOptions).Returns(EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(_textView));
            _recorder = _factory.Create<IMacroRecorder>(MockBehavior.Loose);
            _smartIdentationService = _factory.Create<ISmartIndentationService>();

            _vimData = new VimData();
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _markMap = new MarkMap(new TrackingLineColumnService());
            _globalSettings = new GlobalSettings();
            _localSettings = new LocalSettings(_globalSettings, _textView);

            var localSettings = new LocalSettings(new Vim.GlobalSettings());
            _motionUtil = VimUtil.CreateTextViewMotionUtil(
                _textView,
                settings: localSettings,
                vimData: _vimData);
            _commandUtil = VimUtil.CreateCommandUtil(
                _textView,
                _operations.Object,
                _motionUtil,
                statusUtil: _statusUtil.Object,
                localSettings: _localSettings,
                registerMap: _registerMap,
                markMap: _markMap,
                vimData: _vimData,
                smartIndentationService: _smartIdentationService.Object,
                recorder: _recorder.Object);
            _jumpList = _commandUtil._jumpList;
        }
Example #26
0
 private void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _host = _factory.Create<IVimHost>();
     _statusUtil = _factory.Create<IStatusUtil>();
     _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _vimData = new VimData();
     var settings = new GlobalSettings();
     var localSettings = new LocalSettings(settings, _textView);
     var motionUtil = VimUtil.CreateTextViewMotionUtil(
         _textView,
         settings: localSettings,
         vimData: _vimData);
     var capture = new MotionCapture(
         _host.Object,
         _textView,
         MockObjectFactory.CreateIncrementalSearch(factory: _factory).Object,
         localSettings);
     _commandUtil = VimUtil.CreateCommandUtil(
         _textView,
         motionUtil: motionUtil,
         statusUtil: _statusUtil.Object,
         registerMap: _registerMap,
         vimData: _vimData);
     _runnerRaw = new CommandRunner(
         _textView,
         _registerMap,
         capture,
         _commandUtil,
         _statusUtil.Object,
         VisualKind.Character);
     _runner = _runnerRaw;
 }
Example #27
0
 internal static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     MarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null)
 {
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new TrackingLineColumnService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new FakeVimHost();
     keyMap = keyMap ?? (new KeyMap());
     var mock = new Mock<IVim>(MockBehavior.Strict);
     mock.Setup(x => x.RegisterMap).Returns(registerMap);
     mock.Setup(x => x.MarkMap).Returns(map);
     mock.Setup(x => x.Settings).Returns(settings);
     mock.Setup(x => x.Host).Returns(host);
     mock.Setup(x => x.KeyMap).Returns(keyMap);
     return mock;
 }
Example #28
0
 public ReplaceTest()
 {
     _clipboardDevice = new Mock<IClipboardDevice>(MockBehavior.Loose);
     Func<FSharpOption<string>> func = () => FSharpOption<string>.None;
     _registerMap = new RegisterMap(
         new VimData(_globalSettings),
         _clipboardDevice.Object,
         func.ToFSharpFunc());
 }
Example #29
0
        public static Register GetRegister(this IRegisterMap map, char c)
        {
            var name = RegisterNameUtil.CharToRegister(c).Value;

            return(map.GetRegister(name));
        }
Example #30
0
 public void Create2(
     ModeKind kind = ModeKind.VisualCharacter,
     params string[] lines)
 {
     _textView = EditorUtil.CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _selection = _textView.Selection;
     _factory = new MockRepository(MockBehavior.Strict);
     _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _markMap = new MarkMap(new TrackingLineColumnService());
     _tracker = _factory.Create<ISelectionTracker>();
     _tracker.Setup(x => x.Start());
     _tracker.Setup(x => x.ResetCaret());
     _tracker.Setup(x => x.UpdateSelection());
     _jumpList = _factory.Create<IJumpList>(MockBehavior.Loose);
     _undoRedoOperations = _factory.Create<IUndoRedoOperations>();
     _foldManager = _factory.Create<IFoldManager>();
     _editorOperations = _factory.Create<IEditorOperations>();
     _operations = _factory.Create<ICommonOperations>();
     _operations.SetupGet(x => x.UndoRedoOperations).Returns(_undoRedoOperations.Object);
     _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
     _operations.SetupGet(x => x.TextView).Returns(_textView);
     _host = _factory.Create<IVimHost>(MockBehavior.Loose);
     _commandUtil = _factory.Create<ICommandUtil>();
     _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
     var globalSettings = new GlobalSettings();
     var localSettings = new LocalSettings(globalSettings, EditorUtil.GetEditorOptions(_textView), _textView);
     var motionUtil = VimUtil.CreateTextViewMotionUtil(
         _textView,
         _markMap,
         localSettings);
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _textView,
         "test",
         MockObjectFactory.CreateVim(_map, host: _host.Object, settings: globalSettings).Object,
         incrementalSearch: _incrementalSearch.Object,
         jumpList: _jumpList.Object,
         motionUtil: motionUtil);
     var capture = new MotionCapture(
         _host.Object,
         _textView,
         _incrementalSearch.Object,
         localSettings);
     var runner = new CommandRunner(
         _textView,
         _map,
         capture,
         _commandUtil.Object,
         (new Mock<IStatusUtil>()).Object,
         VisualKind.Character);
     _modeRaw = new VisualMode(_bufferData.Object, _operations.Object, kind, runner, capture, _tracker.Object);
     _mode = _modeRaw;
     _mode.OnEnter(ModeArgument.None);
 }
Example #31
0
 public void Create2(
     ModeKind kind=ModeKind.VisualCharacter,
     params string[] lines)
 {
     _buffer = EditorUtil.CreateBuffer(lines);
     _caret = new Mock<ITextCaret>(MockBehavior.Strict);
     _view = new Mock<IWpfTextView>(MockBehavior.Strict);
     _selection = new Mock<ITextSelection>(MockBehavior.Strict);
     _view.SetupGet(x => x.Caret).Returns(_caret.Object);
     _view.SetupGet(x => x.Selection).Returns(_selection.Object);
     _view.SetupGet(x => x.TextBuffer).Returns(_buffer);
     _view.SetupGet(x => x.TextSnapshot).Returns(() => _buffer.CurrentSnapshot);
     _map = new RegisterMap();
     _tracker = new Mock<ISelectionTracker>(MockBehavior.Strict);
     _tracker.Setup(x => x.Start());
     _operations = new Mock<IOperations>(MockBehavior.Strict);
     _operations.SetupGet(x => x.SelectionTracker).Returns(_tracker.Object);
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _view.Object,
         "test",
         MockObjectFactory.CreateVim(_map).Object);
     var capture = new MotionCapture(_view.Object, new MotionUtil(_view.Object, _bufferData.Object.Settings.GlobalSettings));
     var runner = new CommandRunner(Tuple.Create((ITextView)_view.Object, _map, (IMotionCapture)capture, (new Mock<IStatusUtil>()).Object));
     _modeRaw = new Vim.Modes.Visual.VisualMode(_bufferData.Object, _operations.Object, kind, runner, capture);
     _mode = _modeRaw;
     _mode.OnEnter();
 }
Example #32
0
 public void Create(params string[] lines)
 {
     _view = Utils.EditorUtil.CreateView(lines);
     _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
     _map = new RegisterMap();
     _editorOperations = new Mock<IEditorOperations>();
     _incrementalSearch = new Mock<IIncrementalSearch>(MockBehavior.Strict);
     _jumpList = new Mock<IJumpList>(MockBehavior.Strict);
     _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
     _changeTracker = new Mock<IChangeTracker>(MockBehavior.Strict);
     _displayWindowBroker = new Mock<IDisplayWindowBroker>(MockBehavior.Strict);
     _displayWindowBroker.SetupGet(x => x.IsSmartTagWindowActive).Returns(false);
     _bufferData = MockFactory.CreateVimBuffer(
         _view,
         "test",
         MockFactory.CreateVim(_map,changeTracker:_changeTracker.Object).Object,
         _jumpList.Object);
     _operations = new Mock<IOperations>(MockBehavior.Strict);
     _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
     _operations.SetupGet(x => x.TextView).Returns(_view);
     _modeRaw = new Vim.Modes.Normal.NormalMode(Tuple.Create(_bufferData.Object, _operations.Object, _incrementalSearch.Object, _statusUtil.Object, _displayWindowBroker.Object));
     _mode = _modeRaw;
     _mode.OnEnter();
 }
Example #33
0
 public static Register GetRegister(this CommandData commandData, IRegisterMap registerMap)
 {
     return(registerMap.GetRegister(commandData.GetRegisterNameOrDefault()));
 }
Example #34
0
 private void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _host = _factory.Create<IVimHost>();
     _statusUtil = _factory.Create<IStatusUtil>();
     _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _vimData = new VimData();
     var capture = new MotionCapture(
         _host.Object,
         _textView,
         new TextViewMotionUtil(
             _textView,
             new MarkMap(new TrackingLineColumnService()),
             new Vim.LocalSettings(new Vim.GlobalSettings(), _textView)),
         MockObjectFactory.CreateIncrementalSearch(factory: _factory).Object,
         _factory.Create<IJumpList>().Object,
         _vimData,
         new LocalSettings(new Vim.GlobalSettings(), _textView));
     _runnerRaw = new CommandRunner(
         _textView,
         _registerMap,
         (IMotionCapture)capture,
         _statusUtil.Object);
     _runner = _runnerRaw;
 }
Example #35
0
        public void Create(params string[] lines)
        {
            _context = new TestableSynchronizationContext();
            SynchronizationContext.SetSynchronizationContext(_context);
            var tuple = EditorUtil.CreateTextViewAndEditorOperations(lines);
            _textView = tuple.Item1;
            _textBuffer = _textView.TextBuffer;
            var service = EditorUtil.FactoryService;
            _buffer = service.Vim.CreateVimBuffer(_textView);
            _buffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
            _vimTextBuffer = _buffer.VimTextBuffer;
            _registerMap = _buffer.RegisterMap;
            _globalSettings = _buffer.LocalSettings.GlobalSettings;
            Assert.IsTrue(_context.IsEmpty);

            // Need to make sure it's focused so macro recording will work
            ((MockVimHost)_buffer.Vim.VimHost).FocusedTextView = _textView;
        }
Example #36
0
        public void Create(params string[] lines)
        {
            _view = EditorUtil.CreateView(lines);
            _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
            _buffer = _view.TextBuffer;
            _factory = new MockRepository(MockBehavior.Strict);
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
            _host = _factory.Create<IVimHost>();
            _jumpList = _factory.Create<IJumpList>();
            _editorOpts = _factory.Create<IEditorOperations>();
            _settings = _factory.Create<IVimLocalSettings>();
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _outlining = _factory.Create<IOutliningManager>();
            _globalSettings.SetupGet(x => x.ShiftWidth).Returns(2);
            _settings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
            _undoRedoOperations = _factory.Create<IUndoRedoOperations>();

            var data = new OperationsData(
                vimHost: _host.Object,
                editorOperations: _editorOpts.Object,
                textView: _view,
                outliningManager: _outlining.Object,
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                undoRedoOperations: _undoRedoOperations.Object,
                registerMap: _registerMap,
                editorOptions: null,
                keyMap: null,
                navigator: null,
                statusUtil: null,
                foldManager: null);

            _operationsRaw = new OperationsImpl(data);
            _operations = _operationsRaw;
        }
Example #37
0
        private void Create(params string[] lines)
        {
            _vimHost = (MockVimHost)Vim.VimHost;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimTextBuffer = Vim.CreateVimTextBuffer(_textBuffer);
            _localSettings = _vimTextBuffer.LocalSettings;

            _foldManager = FoldManagerFactory.GetFoldManager(_textView);

            _factory = new MockRepository(MockBehavior.Loose);
            _statusUtil = _factory.Create<IStatusUtil>();
            _smartIdentationService = _factory.Create<ISmartIndentationService>();

            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView,
                statusUtil: _statusUtil.Object);
            _jumpList = vimBufferData.JumpList;
            _windowSettings = vimBufferData.WindowSettings;

            _vimData = Vim.VimData;
            _macroRecorder = Vim.MacroRecorder;
            _registerMap = Vim.RegisterMap;
            _globalSettings = Vim.GlobalSettings;

            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _motionUtil = new MotionUtil(vimBufferData);
            _commandUtil = new CommandUtil(
                vimBufferData,
                _motionUtil,
                operations,
                _smartIdentationService.Object,
                _foldManager,
                new InsertUtil(vimBufferData, operations));
        }
 public void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
     _textBuffer = _textView.TextBuffer;
     _factory = new MockRepository(MockBehavior.Strict);
     _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _editOpts = _factory.Create<IEditorOperations>();
     _vimHost = _factory.Create<IVimHost>();
     _vimHost.Setup(x => x.IsDirty(It.IsAny<ITextBuffer>())).Returns(false);
     _operations = _factory.Create<ICommonOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
     _statusUtil = _factory.Create<IStatusUtil>();
     _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
     _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
     _vimData = new VimData();
     _vim = MockObjectFactory.CreateVim(_registerMap, host: _vimHost.Object, vimData: _vimData, factory: _factory);
     var localSettings = new LocalSettings(Vim.GlobalSettings);
     var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
         _textBuffer,
         vim: _vim.Object,
         localSettings: localSettings,
         factory: _factory);
     var vimBufferData = CreateVimBufferData(
         vimTextBuffer.Object,
         _textView,
         statusUtil: _statusUtil.Object);
     var vimBuffer = CreateVimBuffer(vimBufferData);
     _interpreter = new Interpreter.Interpreter(
         vimBuffer,
         _operations.Object,
         _foldManager.Object,
         _fileSystem.Object,
         _factory.Create<IBufferTrackingService>().Object);
 }
Example #39
0
 public void Create2(
     ModeKind kind = ModeKind.VisualCharacter,
     params string[] lines)
 {
     _buffer = EditorUtil.CreateBuffer(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _caret = _factory.Create<ITextCaret>();
     _view = _factory.Create<IWpfTextView>();
     _selection = _factory.Create<ITextSelection>();
     _selection.Setup(x => x.Clear());
     _selection.SetupSet(x => x.Mode = TextSelectionMode.Stream);
     _view.SetupGet(x => x.Caret).Returns(_caret.Object);
     _view.SetupGet(x => x.Selection).Returns(_selection.Object);
     _view.SetupGet(x => x.TextBuffer).Returns(_buffer);
     _view.SetupGet(x => x.TextSnapshot).Returns(() => _buffer.CurrentSnapshot);
     _view.SetupGet(x => x.IsClosed).Returns(false);
     _map = new RegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _tracker = _factory.Create<ISelectionTracker>();
     _tracker.Setup(x => x.Start());
     _tracker.Setup(x => x.ResetCaret());
     _undoRedoOperations = _factory.Create<IUndoRedoOperations>();
     _foldManager = _factory.Create<IFoldManager>();
     _editorOperations = _factory.Create<IEditorOperations>();
     _operations = _factory.Create<ICommonOperations>();
     _operations.SetupGet(x => x.FoldManager).Returns(_foldManager.Object);
     _operations.SetupGet(x => x.UndoRedoOperations).Returns(_undoRedoOperations.Object);
     _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
     _host = _factory.Create<IVimHost>(MockBehavior.Loose);
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _view.Object,
         "test",
         MockObjectFactory.CreateVim(_map, host: _host.Object).Object,
         factory: _factory);
     var capture = new MotionCapture(
         _host.Object,
         _view.Object,
         new TextViewMotionUtil(_view.Object, new Vim.LocalSettings(_bufferData.Object.Settings.GlobalSettings, _view.Object)),
         new MotionCaptureGlobalData());
     var runner = new CommandRunner(_view.Object, _map, (IMotionCapture)capture, (new Mock<IStatusUtil>()).Object);
     _modeRaw = new Vim.Modes.Visual.VisualMode(_bufferData.Object, _operations.Object, kind, runner, capture, _tracker.Object);
     _mode = _modeRaw;
     _mode.OnEnter(ModeArgument.None);
 }
Example #40
0
 private void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _host = _factory.Create<IVimHost>();
     _statusUtil = _factory.Create<IStatusUtil>();
     _registerMap = new RegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     var capture = new MotionCapture(
         _host.Object,
         _textView,
         new TextViewMotionUtil(_textView, new Vim.LocalSettings(new Vim.GlobalSettings(), _textView)),
         new MotionCaptureGlobalData());
     _runnerRaw = new CommandRunner(
         _textView,
         _registerMap,
         (IMotionCapture)capture,
         _statusUtil.Object);
     _runner = _runnerRaw;
 }
Example #41
0
        public void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateView(lines);
            _vimData = new VimData();
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _textBuffer = _textView.TextBuffer;
            _factory = new MockRepository(MockBehavior.Strict);
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
            _host = _factory.Create<IVimHost>();
            _jumpList = _factory.Create<IJumpList>();
            _editorOptions = _factory.Create<IEditorOptions>();
            _editorOptions.Setup(x => x.GetOptionValue(DefaultOptions.ConvertTabsToSpacesOptionId)).Returns(true);
            _editorOperations = _factory.Create<IEditorOperations>();
            _editorOperations.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editorOperations.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _globalSettings.SetupGet(x => x.UseEditorIndent).Returns(false);
            _globalSettings.SetupGet(x => x.UseEditorTabSettings).Returns(false);
            _settings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object, _factory);
            _settings.SetupGet(x => x.AutoIndent).Returns(false);
            _settings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
            _settings.SetupGet(x => x.ExpandTab).Returns(true);
            _settings.SetupGet(x => x.TabStop).Returns(4);
            _outlining = _factory.Create<IOutliningManager>();
            _globalSettings.SetupGet(x => x.ShiftWidth).Returns(2);
            _statusUtil = _factory.Create<IStatusUtil>();
            _undoRedoOperations = _factory.Create<IUndoRedoOperations>();
            _undoRedoOperations.Setup(x => x.CreateUndoTransaction(It.IsAny<string>())).Returns<string>(name => new UndoTransaction(FSharpOption.Create(EditorUtil.GetUndoHistory(_textView.TextBuffer).CreateTransaction(name))));
            _smartIndent = _factory.Create<ISmartIndentationService>();
            _searchService = new SearchService(EditorUtil.FactoryService.TextSearchService, _globalSettings.Object);

            var data = new OperationsData(
                vimData: _vimData,
                vimHost: _host.Object,
                editorOperations: _editorOperations.Object,
                textView: _textView,
                outliningManager: FSharpOption.Create(_outlining.Object),
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                undoRedoOperations: _undoRedoOperations.Object,
                registerMap: _registerMap,
                editorOptions: _editorOptions.Object,
                keyMap: null,
                navigator: null,
                statusUtil: _statusUtil.Object,
                foldManager: null,
                searchService: _searchService,
                smartIndentationService: _smartIndent.Object);

            _operationsRaw = new CommonOperations(data);
            _operations = _operationsRaw;
        }
Example #42
0
 public void Create2(
     ModeKind kind=ModeKind.VisualCharacter,
     IVimHost host= null,
     params string[] lines)
 {
     _buffer = EditorUtil.CreateBuffer(lines);
     _caret = new Mock<ITextCaret>(MockBehavior.Strict);
     _view = new Mock<IWpfTextView>(MockBehavior.Strict);
     _selection = new Mock<ITextSelection>(MockBehavior.Strict);
     _view.SetupGet(x => x.Caret).Returns(_caret.Object);
     _view.SetupGet(x => x.Selection).Returns(_selection.Object);
     _view.SetupGet(x => x.TextBuffer).Returns(_buffer);
     _view.SetupGet(x => x.TextSnapshot).Returns(() => _buffer.CurrentSnapshot);
     _map = new RegisterMap();
     _editOpts = new Mock<IEditorOperations>(MockBehavior.Strict);
     _tracker = new Mock<ISelectionTracker>(MockBehavior.Strict);
     _tracker.Setup(x => x.Start());
     _operations = new Mock<IOperations>(MockBehavior.Strict);
     _operations.SetupGet(x => x.SelectionTracker).Returns(_tracker.Object);
     host = host ?? new FakeVimHost();
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _view.Object,
         "test",
         MockObjectFactory.CreateVim(_map,host:host).Object,
         _editOpts.Object);
     _modeRaw = new Vim.Modes.Visual.VisualMode(Tuple.Create<IVimBuffer, IOperations, ModeKind>(_bufferData.Object, _operations.Object, kind));
     _mode = _modeRaw;
     _mode.OnEnter();
 }