public void Create(bool haveHistory = true) { _factory = new MockRepository(MockBehavior.Strict); _statusUtil = _factory.Create<IStatusUtil>(); var editorOperationsFactoryService = _factory.Create<IEditorOperationsFactoryService>(); if (haveHistory) { _textUndoHistory = _factory.Create<ITextUndoHistory>(); _textUndoHistory.Setup(x => x.Undo(It.IsAny<int>())).Callback<int>(count => { _undoCount += count; }); _textUndoHistory.Setup(x => x.Redo(It.IsAny<int>())).Callback<int>(count => { _redoCount += count; }); _undoRedoOperationsRaw = new UndoRedoOperations( _statusUtil.Object, FSharpOption.Create(_textUndoHistory.Object), editorOperationsFactoryService.Object); } else { _undoRedoOperationsRaw = new UndoRedoOperations( _statusUtil.Object, FSharpOption<ITextUndoHistory>.None, editorOperationsFactoryService.Object); } _undoRedoOperations = _undoRedoOperationsRaw; }
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 = CreateUndoRedoOperations(); _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; }; }
/// <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)); }
internal static ICommonOperations CreateCommonOperations( ITextView textView, IVimLocalSettings localSettings, IOutliningManager outlining = null, IStatusUtil statusUtil = null, ISearchService searchService = null, IUndoRedoOperations undoRedoOperations = null, IVimData vimData = null, IVimHost vimHost = null, ITextStructureNavigator navigator = null, IClipboardDevice clipboardDevice = null, IFoldManager foldManager = null) { var editorOperations = EditorUtil.GetOperations(textView); var editorOptions = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(textView); var jumpList = new JumpList(new TrackingLineColumnService()); var keyMap = new KeyMap(); foldManager = foldManager ?? new FoldManager(textView.TextBuffer); statusUtil = statusUtil ?? new StatusUtil(); searchService = searchService ?? CreateSearchService(localSettings.GlobalSettings); undoRedoOperations = undoRedoOperations ?? new UndoRedoOperations(statusUtil, FSharpOption <ITextUndoHistory> .None, editorOperations); vimData = vimData ?? new VimData(); vimHost = vimHost ?? new MockVimHost(); navigator = navigator ?? CreateTextStructureNavigator(textView.TextBuffer); clipboardDevice = clipboardDevice ?? new MockClipboardDevice(); var operationsData = new OperationsData( editorOperations, editorOptions, foldManager, jumpList, keyMap, localSettings, outlining != null ? FSharpOption.Create(outlining) : FSharpOption <IOutliningManager> .None, CreateRegisterMap(clipboardDevice), searchService, statusUtil, textView, undoRedoOperations, vimData, vimHost, navigator); return(new CommonOperations(operationsData)); }
internal static ICommonOperations CreateCommonOperations( ITextView textView, IVimLocalSettings localSettings, IOutliningManager outlining = null, IStatusUtil statusUtil = null, ISearchService searchService = null, IUndoRedoOperations undoRedoOperations = null, IVimData vimData = null, IVimHost vimHost = null, ITextStructureNavigator navigator = null, IClipboardDevice clipboardDevice = null, IFoldManager foldManager = null) { var editorOperations = EditorUtil.GetOperations(textView); var editorOptions = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(textView); var jumpList = new JumpList(new TrackingLineColumnService()); var keyMap = new KeyMap(); foldManager = foldManager ?? new FoldManager(textView.TextBuffer); statusUtil = statusUtil ?? new StatusUtil(); searchService = searchService ?? CreateSearchService(localSettings.GlobalSettings); undoRedoOperations = undoRedoOperations ?? new UndoRedoOperations(statusUtil, FSharpOption<ITextUndoHistory>.None); vimData = vimData ?? new VimData(); vimHost = vimHost ?? new MockVimHost(); navigator = navigator ?? CreateTextStructureNavigator(textView.TextBuffer); clipboardDevice = clipboardDevice ?? new MockClipboardDevice(); var operationsData = new OperationsData( editorOperations, editorOptions, foldManager, jumpList, keyMap, localSettings, outlining != null ? FSharpOption.Create(outlining) : FSharpOption<IOutliningManager>.None, CreateRegisterMap(clipboardDevice), searchService, EditorUtil.FactoryService.SmartIndentationService, statusUtil, textView, undoRedoOperations, vimData, vimHost, navigator); return new CommonOperations(operationsData); }
public void Create(bool haveHistory = true) { _factory = new MockFactory(MockBehavior.Strict); _statusUtil = _factory.Create<IStatusUtil>(); if (haveHistory) { _history = _factory.Create<ITextUndoHistory>(); _operationsRaw = new UndoRedoOperations( _statusUtil.Object, FSharpOption.Create(_history.Object)); } else { _operationsRaw = new UndoRedoOperations( _statusUtil.Object, FSharpOption<ITextUndoHistory>.None); } _operations = _operationsRaw; }
public void Create(HistoryKind historyKind = HistoryKind.Mock) { _factory = new MockRepository(MockBehavior.Strict); _statusUtil = _factory.Create <IStatusUtil>(); _textView = CreateTextView(); _textBuffer = _textView.TextBuffer; var editorOperationsFactoryService = _factory.Create <IEditorOperationsFactoryService>(); FSharpOption <ITextUndoHistory> textUndoHistory; switch (historyKind) { case HistoryKind.Mock: _mockUndoHistory = _factory.Create <ITextUndoHistory>(); _mockUndoHistory.Setup(x => x.Undo(It.IsAny <int>())).Callback <int>(count => { _undoCount += count; }); _mockUndoHistory.Setup(x => x.Redo(It.IsAny <int>())).Callback <int>(count => { _redoCount += count; }); textUndoHistory = FSharpOption.Create(_mockUndoHistory.Object); break; case HistoryKind.Basic: textUndoHistory = FSharpOption.Create(BasicUndoHistoryRegistry.TextUndoHistoryRegistry.RegisterHistory(_textBuffer)); break; case HistoryKind.None: textUndoHistory = FSharpOption.CreateForReference <ITextUndoHistory>(null); break; default: Assert.True(false); textUndoHistory = null; break; } _undoRedoOperationsRaw = new UndoRedoOperations( VimHost, _statusUtil.Object, textUndoHistory, editorOperationsFactoryService.Object); _undoRedoOperations = _undoRedoOperationsRaw; }
private void Create(params string[] lines) { _textView = EditorUtil.CreateView(lines); _factory = new MockRepository(MockBehavior.Strict); _editOpts = _factory.Create <IEditorOperations>(); _editOpts.Setup(x => x.AddAfterTextBufferChangePrimitive()); _editOpts.Setup(x => x.AddBeforeTextBufferChangePrimitive()); _host = _factory.Create <IVimHost>(); _jumpList = _factory.Create <IJumpList>(); _registerMap = MockObjectFactory.CreateRegisterMap(factory: _factory); _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); _settings = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object); _keyMap = _factory.Create <IKeyMap>(); _statusUtil = _factory.Create <IStatusUtil>(); _outlining = _factory.Create <IOutliningManager>(); _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object); _searchService = VimUtil.CreateSearchService(_globalSettings.Object); var data = new OperationsData( vimData: new VimData(), vimHost: _host.Object, textView: _textView, editorOperations: _editOpts.Object, outliningManager: FSharpOption.Create(_outlining.Object), statusUtil: _statusUtil.Object, jumpList: _jumpList.Object, localSettings: _settings.Object, keyMap: _keyMap.Object, undoRedoOperations: _undoRedoOperations, editorOptions: null, navigator: null, foldManager: null, registerMap: _registerMap.Object, searchService: _searchService); _operationsRaw = new DefaultOperations(data); _operations = _operationsRaw; }
public void Create(HistoryKind historyKind = HistoryKind.Mock) { _factory = new MockRepository(MockBehavior.Strict); _statusUtil = _factory.Create<IStatusUtil>(); _textView = CreateTextView(); _textBuffer = _textView.TextBuffer; var editorOperationsFactoryService = _factory.Create<IEditorOperationsFactoryService>(); FSharpOption<ITextUndoHistory> textUndoHistory; switch (historyKind) { case HistoryKind.Mock: _mockUndoHistory = _factory.Create<ITextUndoHistory>(); _mockUndoHistory.Setup(x => x.Undo(It.IsAny<int>())).Callback<int>(count => { _undoCount += count; }); _mockUndoHistory.Setup(x => x.Redo(It.IsAny<int>())).Callback<int>(count => { _redoCount += count; }); textUndoHistory = FSharpOption.Create(_mockUndoHistory.Object); break; case HistoryKind.Basic: textUndoHistory = FSharpOption.Create(BasicUndoHistoryRegistry.TextUndoHistoryRegistry.RegisterHistory(_textBuffer)); break; case HistoryKind.None: textUndoHistory = FSharpOption.CreateForReference<ITextUndoHistory>(null); break; default: Assert.True(false); textUndoHistory = null; break; } _undoRedoOperationsRaw = new UndoRedoOperations( VimHost, _statusUtil.Object, textUndoHistory, editorOperationsFactoryService.Object); _undoRedoOperations = _undoRedoOperationsRaw; }
public void Create(bool haveHistory = true) { _factory = new MockRepository(MockBehavior.Strict); _editorOperations = _factory.Create <IEditorOperations>(); _statusUtil = _factory.Create <IStatusUtil>(); if (haveHistory) { _history = _factory.Create <ITextUndoHistory>(); _operationsRaw = new UndoRedoOperations( _statusUtil.Object, FSharpOption.Create(_history.Object), _editorOperations.Object); } else { _operationsRaw = new UndoRedoOperations( _statusUtil.Object, FSharpOption <ITextUndoHistory> .None, _editorOperations.Object); } _operations = _operationsRaw; }
/// <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 Mock over IVimTextBuffer which provides the msot basic functions /// </summary> public static Mock<IVimTextBuffer> CreateVimTextBuffer( ITextBuffer textBuffer, IVimLocalSettings localSettings = null, IVim vim = null, ITextStructureNavigator wordNavigator = null, IUndoRedoOperations undoRedoOperations = null, MockRepository factory = null) { factory = factory ?? new MockRepository(MockBehavior.Strict); vim = vim ?? CreateVim(factory: factory).Object; localSettings = localSettings ?? CreateLocalSettings(factory: factory).Object; wordNavigator = wordNavigator ?? factory.Create<ITextStructureNavigator>().Object; undoRedoOperations = undoRedoOperations ?? factory.Create<IUndoRedoOperations>().Object; var mock = factory.Create<IVimTextBuffer>(); mock.SetupGet(x => x.TextBuffer).Returns(textBuffer); mock.SetupGet(x => x.LocalSettings).Returns(localSettings); mock.SetupGet(x => x.GlobalSettings).Returns(localSettings.GlobalSettings); mock.SetupGet(x => x.Vim).Returns(vim); mock.SetupGet(x => x.WordNavigator).Returns(wordNavigator); mock.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal); mock.SetupGet(x => x.UndoRedoOperations).Returns(undoRedoOperations); mock.SetupProperty(x => x.LastVisualSelection); mock.SetupProperty(x => x.LastInsertExitPoint); mock.SetupProperty(x => x.LastEditPoint); mock.Setup(x => x.SwitchMode(It.IsAny<ModeKind>(), It.IsAny<ModeArgument>())); return mock; }
/// <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); }
protected void Create(bool insertMode, params string[] lines) { _factory = new MockRepository(MockBehavior.Strict) { 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); _insertUtil = _factory.Create <IInsertUtil>(); _insertUtil.Setup(x => x.NewUndoSequence()); _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, _wordCompletionSessionFactoryService.Object); _mode = _modeRaw; _mode.OnEnter(ModeArgument.None); _mode.CommandRan += (sender, e) => { _lastCommandRan = e.CommandRunData; }; }
/// <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( 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); }
public void Create(params string[] lines) { _textView = CreateTextView(lines); _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0)); _textBuffer = _textView.TextBuffer; _foldManager = FoldManagerFactory.GetFoldManager(_textView); _factory = new MockRepository(MockBehavior.Strict); // Create the Vim instance with our Mock'd services _vimData = new VimData(); var registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object); _vimHost = _factory.Create<IVimHost>(); _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.SelectionKind).Returns(SelectionKind.Inclusive); _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); _globalSettings.SetupGet(x => x.ShiftWidth).Returns(2); _searchService = new SearchService(TextSearchService, _globalSettings.Object); var vim = MockObjectFactory.CreateVim( registerMap: registerMap, host: _vimHost.Object, settings: _globalSettings.Object, searchService: _searchService, factory: _factory); // Create the IVimTextBuffer instance with our Mock'd services _localSettings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object, _factory); _localSettings.SetupGet(x => x.AutoIndent).Returns(false); _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object); _localSettings.SetupGet(x => x.ExpandTab).Returns(true); _localSettings.SetupGet(x => x.TabStop).Returns(4); _vimTextBuffer = MockObjectFactory.CreateVimTextBuffer( _textBuffer, localSettings: _localSettings.Object, vim: vim.Object, factory: _factory); // Create the VimBufferData instance with our Mock'd services _jumpList = _factory.Create<IJumpList>(); _statusUtil = _factory.Create<IStatusUtil>(); _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object); var vimBufferData = CreateVimBufferData( _vimTextBuffer.Object, _textView, statusUtil: _statusUtil.Object, jumpList: _jumpList.Object, undoRedoOperations: _undoRedoOperations); _smartIndentationService = _factory.Create<ISmartIndentationService>(); _outlining = _factory.Create<IOutliningManager>(); _outlining .Setup(x => x.ExpandAll(It.IsAny<SnapshotSpan>(), It.IsAny<Predicate<ICollapsed>>())) .Returns<IEnumerable<ICollapsible>>(null); _operationsRaw = new CommonOperations( vimBufferData, EditorOperationsFactoryService.GetEditorOperations(_textView), FSharpOption.Create(_outlining.Object), _smartIndentationService.Object); _operations = _operationsRaw; }
internal OperationsImpl(ITextView view, IEditorOperations opts, IOutliningManager outlining, IVimHost host, IJumpList jumpList, IVimLocalSettings settings, IUndoRedoOperations undoRedoOpts) : base(view, opts, outlining, host, jumpList, settings, undoRedoOpts) { }
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); // Create the Vim instance with our Mock'd services _vimData = new VimData(); var registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object); _vimHost = _factory.Create <IVimHost>(); _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); _globalSettings.SetupGet(x => x.ShiftWidth).Returns(2); _searchService = VimUtil.CreateSearchService(_globalSettings.Object); var vim = MockObjectFactory.CreateVim( registerMap: registerMap, host: _vimHost.Object, settings: _globalSettings.Object, searchService: _searchService, factory: _factory); // Create the IVimTextBuffer instance with our Mock'd services _localSettings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object, _factory); _localSettings.SetupGet(x => x.AutoIndent).Returns(false); _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object); _localSettings.SetupGet(x => x.ExpandTab).Returns(true); _localSettings.SetupGet(x => x.TabStop).Returns(4); var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer( _textBuffer, localSettings: _localSettings.Object, vim: vim.Object, factory: _factory); // Create the VimBufferData instance with our Mock'd services _jumpList = _factory.Create <IJumpList>(); _statusUtil = _factory.Create <IStatusUtil>(); _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object); var vimBufferData = CreateVimBufferData( vimTextBuffer.Object, _textView, statusUtil: _statusUtil.Object, jumpList: _jumpList.Object, undoRedoOperations: _undoRedoOperations); _smartIndentationService = _factory.Create <ISmartIndentationService>(); _outlining = _factory.Create <IOutliningManager>(); _outlining .Setup(x => x.ExpandAll(It.IsAny <SnapshotSpan>(), It.IsAny <Predicate <ICollapsed> >())) .Returns <IEnumerable <ICollapsible> >(null); _operationsRaw = new CommonOperations( vimBufferData, EditorOperationsFactoryService.GetEditorOperations(_textView), FSharpOption.Create(_outlining.Object), _smartIndentationService.Object); _operations = _operationsRaw; }
public void Create(params string[] lines) { _textView = EditorUtil.CreateView(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.UseEditorIndent).Returns(false); _globalSettings.SetupGet(x => x.UseEditorTabSettings).Returns(false); _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, navigator: null, statusUtil: _statusUtil.Object, foldManager: null, searchService: _searchService); _operationsRaw = new CommonOperations(data); _operations = _operationsRaw; }
private void Create(params string[] lines) { _textView = EditorUtil.CreateTextView(lines); _factory = new MockRepository(MockBehavior.Strict); _editOpts = _factory.Create<IEditorOperations>(); _editOpts.Setup(x => x.AddAfterTextBufferChangePrimitive()); _editOpts.Setup(x => x.AddBeforeTextBufferChangePrimitive()); _host = _factory.Create<IVimHost>(); _jumpList = _factory.Create<IJumpList>(); _registerMap = MockObjectFactory.CreateRegisterMap(factory: _factory); _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); _localSettings = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object); _keyMap = _factory.Create<IKeyMap>(); _statusUtil = _factory.Create<IStatusUtil>(); _outlining = _factory.Create<IOutliningManager>(); _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object); _searchService = VimUtil.CreateSearchService(_globalSettings.Object); var vimData = new VimData(); var data = new OperationsData( vimData: vimData, vimHost: _host.Object, textView: _textView, editorOperations: _editOpts.Object, outliningManager: FSharpOption.Create(_outlining.Object), statusUtil: _statusUtil.Object, jumpList: _jumpList.Object, localSettings: _localSettings.Object, keyMap: _keyMap.Object, undoRedoOperations: _undoRedoOperations, editorOptions: null, foldManager: null, registerMap: _registerMap.Object, searchService: _searchService, wordUtil: VimUtil.GetWordUtil(_textView)); _operationsRaw = new DefaultOperations( new CommonOperations(data), _textView, _editOpts.Object, _jumpList.Object, _localSettings.Object, _undoRedoOperations, _keyMap.Object, vimData, _host.Object, _statusUtil.Object); _operations = _operationsRaw; }
private void Create(params string[] lines) { _textView = CreateTextView(lines); _factory = new MockRepository(MockBehavior.Strict); _vimHost = _factory.Create<IVimHost>(); var registerMap = MockObjectFactory.CreateRegisterMap(factory: _factory); _keyMap = _factory.Create<IKeyMap>(); _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); _searchService = VimUtil.CreateSearchService(_globalSettings.Object); // Initialize the Mock<IVim> with all of our Mock'd services var vim = MockObjectFactory.CreateVim( registerMap: registerMap.Object, host: _vimHost.Object, keyMap: _keyMap.Object, searchService: _searchService, settings: _globalSettings.Object, vimData: new VimData()); _localSettings = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object); _vimTextBuffer = MockObjectFactory.CreateVimTextBuffer( _textView.TextBuffer, localSettings: _localSettings.Object, vim: vim.Object, factory: _factory); // Initialize the VimBufferData with all of our Mock'd services _jumpList = _factory.Create<IJumpList>(); _statusUtil = _factory.Create<IStatusUtil>(); _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object); var vimBufferData = CreateVimBufferData( _vimTextBuffer.Object, _textView, statusUtil: _statusUtil.Object, jumpList: _jumpList.Object, undoRedoOperations: _undoRedoOperations); _outlining = _factory.Create<IOutliningManager>(); _editorOperations = _factory.Create<IEditorOperations>(); _editorOperations.Setup(x => x.AddAfterTextBufferChangePrimitive()); _editorOperations.Setup(x => x.AddBeforeTextBufferChangePrimitive()); var commonOperations = new CommonOperations( vimBufferData, _editorOperations.Object, FSharpOption.Create(_outlining.Object)); _operationsRaw = new DefaultOperations( vimBufferData, commonOperations); _operations = _operationsRaw; }