protected void Create(params string[] lines) { _vimHost = (MockVimHost)Vim.VimHost; _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _vimTextBuffer = Vim.CreateVimTextBuffer(_textBuffer); _localSettings = _vimTextBuffer.LocalSettings; var foldManager = CreateFoldManager(_textView); _factory = new MockRepository(MockBehavior.Loose); _statusUtil = _factory.Create<IStatusUtil>(); _bulkOperations = new TestableBulkOperations(); var vimBufferData = CreateVimBufferData( _vimTextBuffer, _textView, statusUtil: _statusUtil.Object); _jumpList = vimBufferData.JumpList; _windowSettings = vimBufferData.WindowSettings; _vimData = Vim.VimData; _macroRecorder = Vim.MacroRecorder; _globalSettings = Vim.GlobalSettings; var operations = CreateCommonOperations(vimBufferData); _motionUtil = new MotionUtil(vimBufferData, operations); _commandUtil = new CommandUtil( vimBufferData, _motionUtil, operations, foldManager, new InsertUtil(vimBufferData, operations), _bulkOperations); }
/// <summary> /// This is not technically a Mock but often we want to create it with mocked /// backing values /// </summary> /// <returns></returns> public static IVimBufferData CreateVimBufferData( IVimTextBuffer vimTextBuffer, ITextView textView, IJumpList jumpList = null, IStatusUtil statusUtil = null, IUndoRedoOperations undoRedoOperations = null, IVimWindowSettings windowSettings = null, IWordUtil wordUtil = null, MockRepository factory = null) { factory = factory ?? new MockRepository(MockBehavior.Strict); statusUtil = statusUtil ?? factory.Create <IStatusUtil>().Object; undoRedoOperations = undoRedoOperations ?? factory.Create <IUndoRedoOperations>().Object; jumpList = jumpList ?? factory.Create <IJumpList>().Object; wordUtil = wordUtil ?? factory.Create <IWordUtil>().Object; windowSettings = windowSettings ?? factory.Create <IVimWindowSettings>().Object; return(new VimBufferData( vimTextBuffer, textView, windowSettings, jumpList, statusUtil, undoRedoOperations, wordUtil)); }
private void Create(params string[] lines) { _vimTextBuffer = CreateVimTextBuffer(lines); _textBuffer = _vimTextBuffer.TextBuffer; _localSettings = _vimTextBuffer.LocalSettings; _globalSettings = _localSettings.GlobalSettings; }
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; }
/// <summary> /// This is not technically a Mock but often we want to create it with mocked /// backing values /// </summary> /// <returns></returns> public static IVimBufferData CreateVimBufferData( IVimTextBuffer vimTextBuffer, ITextView textView, IJumpList jumpList = null, IStatusUtil statusUtil = null, IVimWindowSettings windowSettings = null, ICaretRegisterMap caretRegisterMap = null, ISelectionUtil selectionUtil = null, MockRepository factory = null) { factory = factory ?? new MockRepository(MockBehavior.Strict); statusUtil = statusUtil ?? factory.Create <IStatusUtil>().Object; jumpList = jumpList ?? factory.Create <IJumpList>().Object; windowSettings = windowSettings ?? factory.Create <IVimWindowSettings>().Object; caretRegisterMap = caretRegisterMap ?? factory.Create <ICaretRegisterMap>().Object; selectionUtil = selectionUtil ?? new SingleSelectionUtil(textView); return(new VimBufferData( vimTextBuffer, textView, windowSettings, jumpList, statusUtil, selectionUtil, caretRegisterMap)); }
private void Create(params string[] lines) { _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; var vimBufferData = CreateVimBufferData(_textView); _vimTextBuffer = vimBufferData.VimTextBuffer; _rangeUtil = new RangeUtil(vimBufferData); }
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; }
/// <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( IVimTextBuffer vimTextBuffer, ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IVimWindowSettings windowSettings = null) { jumpList = jumpList ?? new JumpList(textView, BufferTrackingService); statusUtil = statusUtil ?? new StatusUtil(); windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings); return(new VimBufferData( vimTextBuffer, textView, windowSettings, jumpList, statusUtil)); }
protected void Create(ITextView textView) { _textView = textView; _textBuffer = textView.TextBuffer; _snapshot = _textBuffer.CurrentSnapshot; _textBuffer.Changed += delegate { _snapshot = _textBuffer.CurrentSnapshot; }; _vimTextBuffer = Vim.CreateVimTextBuffer(_textBuffer); _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict); var vimBufferData = CreateVimBufferData(_vimTextBuffer, _textView, statusUtil: _statusUtil.Object); _globalSettings = vimBufferData.LocalSettings.GlobalSettings; _localSettings = vimBufferData.LocalSettings; _markMap = vimBufferData.Vim.MarkMap; _vimData = vimBufferData.Vim.VimData; _search = vimBufferData.Vim.SearchService; var wordNavigator = CreateTextStructureNavigator(_textView.TextBuffer, WordKind.NormalWord); _motionUtil = new MotionUtil(vimBufferData); }
protected virtual void Create(params string[] lines) { _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _vimBuffer = Vim.CreateVimBuffer(_textView); _vimBuffer.ErrorMessage += (_, message) => { if (_assertOnErrorMessage) { throw new Exception("Error Message: " + message.Message); } }; _vimBuffer.WarningMessage += (_, message) => { if (_assertOnWarningMessage) { throw new Exception("Warning Message: " + message.Message); } }; _vimBufferData = _vimBuffer.VimBufferData; _vimTextBuffer = _vimBuffer.VimTextBuffer; _normalMode = _vimBuffer.NormalMode; _keyMap = _vimBuffer.Vim.KeyMap; _localSettings = _vimBuffer.LocalSettings; _globalSettings = _localSettings.GlobalSettings; _windowSettings = _vimBuffer.WindowSettings; _jumpList = _vimBuffer.JumpList; _vimHost = (MockVimHost)_vimBuffer.Vim.VimHost; _vimHost.BeepCount = 0; _vimData = Vim.VimData; _foldManager = FoldManagerFactory.GetFoldManager(_textView); _clipboardDevice = (TestableClipboardDevice)CompositionContainer.GetExportedValue<IClipboardDevice>(); // Many of the operations operate on both the visual and edit / text snapshot // simultaneously. Ensure that our setup code is producing a proper IElisionSnapshot // for the Visual portion so we can root out any bad mixing of instances between // the two Assert.True(_textView.VisualSnapshot is IElisionSnapshot); Assert.True(_textView.VisualSnapshot != _textView.TextSnapshot); }
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; }
protected 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); _keyMap = Vim.KeyMap; }
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; }
/// <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( IVimTextBuffer vimTextBuffer, ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IVimWindowSettings windowSettings = null, ICaretRegisterMap caretRegisterMap = null, ISelectionUtil selectionUtil = null) { jumpList = jumpList ?? new JumpList(textView, BufferTrackingService); statusUtil = statusUtil ?? CompositionContainer.GetExportedValue <IStatusUtilFactory>().GetStatusUtilForView(textView); windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings); caretRegisterMap = caretRegisterMap ?? new CaretRegisterMap(Vim.RegisterMap); selectionUtil = selectionUtil ?? new SingleSelectionUtil(textView); return(new VimBufferData( vimTextBuffer, textView, windowSettings, jumpList, statusUtil, selectionUtil, caretRegisterMap)); }
/// <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( IVimTextBuffer vimTextBuffer, ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IUndoRedoOperations undoRedoOperations = null, IVimWindowSettings windowSettings = null, IWordUtil wordUtil = null) { jumpList = jumpList ?? new JumpList(textView, _bufferTrackingService); statusUtil = statusUtil ?? new StatusUtil(); undoRedoOperations = undoRedoOperations ?? CreateUndoRedoOperations(statusUtil); windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings); wordUtil = wordUtil ?? WordUtilFactory.GetWordUtil(vimTextBuffer.TextBuffer); return(new VimBufferData( vimTextBuffer, textView, windowSettings, jumpList, statusUtil, undoRedoOperations, 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( IVimTextBuffer vimTextBuffer, ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IUndoRedoOperations undoRedoOperations = null, IVimWindowSettings windowSettings = null, IWordUtil wordUtil = null) { jumpList = jumpList ?? new JumpList(textView, _bufferTrackingService); statusUtil = statusUtil ?? new StatusUtil(); undoRedoOperations = undoRedoOperations ?? CreateUndoRedoOperations(statusUtil); windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings); wordUtil = wordUtil ?? WordUtilFactory.GetWordUtil(vimTextBuffer.TextBuffer); return new VimBufferData( vimTextBuffer, textView, windowSettings, jumpList, statusUtil, undoRedoOperations, 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( IVimTextBuffer vimTextBuffer, ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IVimWindowSettings windowSettings = null, IWordUtil wordUtil = null) { jumpList = jumpList ?? new JumpList(textView, BufferTrackingService); statusUtil = statusUtil ?? new StatusUtil(); windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings); wordUtil = wordUtil ?? WordUtil; return new VimBufferData( vimTextBuffer, textView, windowSettings, jumpList, statusUtil, wordUtil); }
private void Create(params string[] lines) { _vimTextBuffer = CreateVimTextBuffer(lines); _textBuffer = _vimTextBuffer.TextBuffer; }
internal BufferInfo(IVimTextBuffer vimTextBuffer, string name = "<unnamed>") { _vimTextBuffer = vimTextBuffer; _name = name; }
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)); }
/// <summary> /// This is not technically a Mock but often we want to create it with mocked /// backing values /// </summary> /// <returns></returns> public static VimBufferData CreateVimBufferData( IVimTextBuffer vimTextBuffer, ITextView textView, IJumpList jumpList = null, IStatusUtil statusUtil = null, IUndoRedoOperations undoRedoOperations = null, IVimWindowSettings windowSettings = null, IWordUtil wordUtil = null, MockRepository factory = null) { factory = factory ?? new MockRepository(MockBehavior.Strict); statusUtil = statusUtil ?? factory.Create<IStatusUtil>().Object; undoRedoOperations = undoRedoOperations ?? factory.Create<IUndoRedoOperations>().Object; jumpList = jumpList ?? factory.Create<IJumpList>().Object; wordUtil = wordUtil ?? factory.Create<IWordUtil>().Object; windowSettings = windowSettings ?? factory.Create<IVimWindowSettings>().Object; return new VimBufferData( jumpList, textView, statusUtil, undoRedoOperations, vimTextBuffer, windowSettings, wordUtil); }
internal static IVimBuffer CreateVimBuffer(this IVimBufferFactory vimBufferFactory, ITextView textView, IVimTextBuffer vimTextBuffer) { var vimBufferData = vimBufferFactory.CreateVimBufferData(vimTextBuffer, textView); return(vimBufferFactory.CreateVimBuffer(vimBufferData)); }
public void Create(params string[] lines) { var tuple = EditorUtil.CreateTextViewAndEditorOperations(lines); _textView = tuple.Item1; _textBuffer = _textView.TextBuffer; var service = EditorUtil.FactoryService; _vimBuffer = service.Vim.CreateVimBuffer(_textView); _vimBuffer.ErrorMessage += (_, message) => { if (_assertOnErrorMessage) { Assert.Fail("Error Message: " + message); } }; _vimBuffer.WarningMessage += (_, message) => { if (_assertOnWarningMessage) { Assert.Fail("Warning Message: " + message); } }; _vimTextBuffer = _vimBuffer.VimTextBuffer; _keyMap = _vimBuffer.Vim.KeyMap; _globalSettings = _vimBuffer.LocalSettings.GlobalSettings; _jumpList = _vimBuffer.JumpList; _vimHost = (MockVimHost)_vimBuffer.Vim.VimHost; _vimHost.BeepCount = 0; _vimData = service.Vim.VimData; _foldManager = EditorUtil.FactoryService.FoldManagerFactory.GetFoldManager(_textView); // Many of the operations operate on both the visual and edit / text snapshot // simultaneously. Ensure that our setup code is producing a proper IElisionSnapshot // for the Visual portion so we can root out any bad mixing of instances between // the two Assert.IsTrue(_textView.VisualSnapshot is IElisionSnapshot); Assert.IsTrue(_textView.VisualSnapshot != _textView.TextSnapshot); }