protected void Create(bool insertMode, params string[] lines) { _factory = new MockRepository(MockBehavior.Strict); _factory.DefaultValue = DefaultValue.Mock; _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _vim = _factory.Create <IVim>(MockBehavior.Loose); _editorOptions = _factory.Create <IEditorOptions>(MockBehavior.Loose); _textChangeTracker = _factory.Create <ITextChangeTracker>(MockBehavior.Loose); _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption <TextChange> .None); _undoRedoOperations = new UndoRedoOperations(VimHost, new StatusUtil(), FSharpOption <ITextUndoHistory> .None, null); _wordCompletionSessionFactoryService = _factory.Create <IWordCompletionSessionFactoryService>(); var localSettings = new LocalSettings(Vim.GlobalSettings); _vimBuffer = Vim.CreateVimBuffer(_textView); _globalSettings = _vimBuffer.GlobalSettings; var vimTextBuffer = Vim.GetOrCreateVimTextBuffer(_textView.TextBuffer); var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView); _operations = CommonOperationsFactory.GetCommonOperations(vimBufferData); _broker = _factory.Create <IDisplayWindowBroker>(); _broker.SetupGet(x => x.IsCompletionActive).Returns(false); _broker.SetupGet(x => x.IsQuickInfoActive).Returns(false); _broker.SetupGet(x => x.IsSignatureHelpActive).Returns(false); _broker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false); _insertUtil = _factory.Create <IInsertUtil>(); _motionUtil = _factory.Create <IMotionUtil>(); _commandUtil = _factory.Create <ICommandUtil>(); _capture = _factory.Create <IMotionCapture>(); // Setup the mouse. By default we say it has no buttons down as that's the normal state _mouseDevice = _factory.Create <IMouseDevice>(); _mouseDevice.SetupGet(x => x.IsLeftButtonPressed).Returns(false); // Setup the keyboard. By default we don't say that any button is pressed. Insert mode is usually // only concerned with arrow keys and we will set those up as appropriate for the typing tests _keyboardDevice = _factory.Create <IKeyboardDevice>(); _keyboardDevice.Setup(x => x.IsArrowKeyDown).Returns(false); _modeRaw = new global::Vim.Modes.Insert.InsertMode( _vimBuffer, _operations, _broker.Object, _editorOptions.Object, _undoRedoOperations, _textChangeTracker.Object, _insertUtil.Object, _motionUtil.Object, _commandUtil.Object, _capture.Object, !insertMode, _keyboardDevice.Object, _mouseDevice.Object, WordUtil, _wordCompletionSessionFactoryService.Object); _mode = _modeRaw; _mode.OnEnter(ModeArgument.None); _mode.CommandRan += (sender, e) => { _lastCommandRan = e.CommandRunData; }; }
public void GetOrCreateVimBufferForHost_VimTextBufferAlreadyCreated() { VimHost.ShouldCreateVimBufferImpl = true; var textView = CreateTextView(""); var vimTextBuffer = Vim.GetOrCreateVimTextBuffer(textView.TextBuffer); Assert.True(Vim.TryGetOrCreateVimBufferForHost(textView, out IVimBuffer vimBuffer)); Assert.Same(textView, vimBuffer.TextView); Assert.Same(vimTextBuffer, vimBuffer.VimTextBuffer); }
/// <summary> /// Create a new instance of VimBufferData. Centralized here to make it easier to /// absorb API changes in the Unit Tests /// </summary> protected IVimBufferData CreateVimBufferData( ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IVimWindowSettings windowSettings = null) { return(CreateVimBufferData( Vim.GetOrCreateVimTextBuffer(textView.TextBuffer), textView, statusUtil, jumpList, windowSettings)); }
/// <summary> /// Create a new instance of VimBufferData. Centralized here to make it easier to /// absorb API changes in the Unit Tests /// </summary> protected IVimBufferData CreateVimBufferData( ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IUndoRedoOperations undoRedoOperations = null, IVimWindowSettings windowSettings = null, IWordUtil wordUtil = null) { return(CreateVimBufferData( Vim.GetOrCreateVimTextBuffer(textView.TextBuffer), textView, statusUtil, jumpList, undoRedoOperations, windowSettings, wordUtil)); }
/// <summary> /// Create a new instance of VimBufferData. Centralized here to make it easier to /// absorb API changes in the Unit Tests /// </summary> protected IVimBufferData CreateVimBufferData( ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IVimWindowSettings windowSettings = null, ICaretRegisterMap caretRegisterMap = null, ISelectionUtil selectionUtil = null) { return(CreateVimBufferData( Vim.GetOrCreateVimTextBuffer(textView.TextBuffer), textView, statusUtil, jumpList, windowSettings, caretRegisterMap, selectionUtil)); }