public EditorToSettingSynchronizerTest() { _synchronizer = new EditorToSettingSynchronizer(); var textView = CreateTextView(); var globalSettings = new GlobalSettings(); _localSettings = new LocalSettings(globalSettings); _windowSettings = new WindowSettings(globalSettings); _editorOptions = textView.Options; var vim = new Mock <IVim>(MockBehavior.Strict); vim.SetupGet(x => x.VimHost).Returns(VimHost); _vimBuffer = new Mock <IVimBuffer>(MockBehavior.Strict); _vimBuffer.SetupGet(x => x.LocalSettings).Returns(_localSettings); _vimBuffer.SetupGet(x => x.WindowSettings).Returns(_windowSettings); _vimBuffer.SetupGet(x => x.TextView).Returns(textView); _vimBuffer.SetupGet(x => x.Vim).Returns(vim.Object); _vimTextBuffer = new Mock <IVimTextBuffer>(MockBehavior.Strict); _vimTextBuffer.Setup(x => x.CheckModeLine()).Returns(Tuple.Create(FSharpOption <string> .None, FSharpOption <string> .None)); _vimBuffer.SetupGet(x => x.Vim).Returns(vim.Object); _vimBuffer.SetupGet(x => x.VimTextBuffer).Returns(_vimTextBuffer.Object); }
/// <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)); }
/// <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)); }
/// <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)); }
public EditorToSettingSynchronizerTest() { _synchronizer = new EditorToSettingSynchronizer(); var textView = CreateTextView(); var globalSettings = new GlobalSettings(); _localSettings = new LocalSettings(globalSettings); _windowSettings = new WindowSettings(globalSettings); _editorOptions = textView.Options; _vimBuffer = new Mock<IVimBuffer>(MockBehavior.Strict); _vimBuffer.SetupGet(x => x.LocalSettings).Returns(_localSettings); _vimBuffer.SetupGet(x => x.WindowSettings).Returns(_windowSettings); _vimBuffer.SetupGet(x => x.TextView).Returns(textView); }
public EditorToSettingSynchronizerTest() { _synchronizer = new EditorToSettingSynchronizer(); var textView = CreateTextView(); var globalSettings = new GlobalSettings(); _localSettings = new LocalSettings(globalSettings); _windowSettings = new WindowSettings(globalSettings); _editorOptions = textView.Options; _vimBuffer = new Mock <IVimBuffer>(MockBehavior.Strict); _vimBuffer.SetupGet(x => x.LocalSettings).Returns(_localSettings); _vimBuffer.SetupGet(x => x.WindowSettings).Returns(_windowSettings); _vimBuffer.SetupGet(x => x.TextView).Returns(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)); }
/// <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)); }
/// <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)); }
protected virtual void Create(params string[] lines) { _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _mockMultiSelectionUtil = new MockSelectionUtil(_textView, isMultiSelectionSupported: true); VimHost.TryCustomProcessFunc = (_, command) => _mockMultiSelectionUtil.TryCustomProcess(command); var vimBufferData = CreateVimBufferData(_textView, null, null, null, null, _mockMultiSelectionUtil); _vimBuffer = Vim.CreateVimBufferWithData(vimBufferData); _localSettings = _vimBuffer.LocalSettings; _globalSettings = _localSettings.GlobalSettings; _windowSettings = _vimBuffer.WindowSettings; _selectionUtil = _vimBuffer.VimBufferData.SelectionUtil; _testableMouseDevice = (TestableMouseDevice)MouseDevice; _testableMouseDevice.IsLeftButtonPressed = false; _testableMouseDevice.Point = null; }
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); }
protected void Create(params string[] lines) { _vimHost = (MockVimHost)Vim.VimHost; _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _vimTextBuffer = CreateVimTextBufferCore(_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); var lineChangeTracker = new LineChangeTracker(vimBufferData); _motionUtil = new MotionUtil(vimBufferData, operations); _commandUtil = new CommandUtil( vimBufferData, _motionUtil, operations, foldManager, new InsertUtil(vimBufferData, _motionUtil, operations), _bulkOperations, MouseDevice, lineChangeTracker); var outliningManagerService = CompositionContainer.GetExportedValue<IOutliningManagerService>(); _outliningManager = outliningManagerService.GetOutliningManager(_textView); }
protected virtual void Create(params string[] lines) { _statusUtil = new TestableStatusUtil(); _vimData = Vim.VimData; _vimBufferData = CreateVimBufferData( CreateTextView(lines), statusUtil: _statusUtil); _vimBuffer = CreateVimBuffer(_vimBufferData); _vimTextBuffer = _vimBufferData.VimTextBuffer; _windowSettings = _vimBufferData.WindowSettings; _localSettings = _vimBufferData.LocalSettings; _globalSettings = _localSettings.GlobalSettings; _textBuffer = _vimBufferData.TextBuffer; _textView = _vimBufferData.TextView; _interpreter = new global::Vim.Interpreter.VimInterpreter( _vimBuffer, CommonOperationsFactory.GetCommonOperations(_vimBufferData), FoldManagerFactory.GetFoldManager(_vimBufferData.TextView), new FileSystem(), BufferTrackingService); _keyMap = Vim.KeyMap; }
/// <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> /// 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); }
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> /// 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); }
public virtual void VimRcLoaded(VimRcState vimRcState, IVimLocalSettings localSettings, IVimWindowSettings windowSettings) { }
void IVimHost.VimRcLoaded(VimRcState vimRcState, IVimLocalSettings localSettings, IVimWindowSettings windowSettings) { VimRcLoaded(vimRcState, localSettings, 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( 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); }
public void VimRcLoaded(VimRcState vimRcState, IVimLocalSettings localSettings, IVimWindowSettings windowSettings) { //throw new NotImplementedException(); }
public override void VimRcLoaded(VimRcState vimRcState, IVimLocalSettings localSettings, IVimWindowSettings windowSettings) { if (vimRcState.IsLoadFailed) { // If we failed to load a vimrc file then we should add a couple of sanity // settings. Otherwise the Visual Studio experience wont't be what users expect localSettings.AutoIndent = true; } }
void IVimHost.VimRcLoaded(VimRcState vimRcState, IVimLocalSettings localSettings, IVimWindowSettings windowSettings) { VimRcState = vimRcState; }
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 = CommonOperationsFactory.GetCommonOperations(vimBufferData); _motionUtil = new MotionUtil(vimBufferData); _commandUtil = new CommandUtil( vimBufferData, _motionUtil, operations, foldManager, new InsertUtil(vimBufferData, operations), _bulkOperations); }
protected override void Create(params string[] lines) { base.Create(lines); _windowSettings = new WindowSettings(_globalSettings); }