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); }
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; }
public void Setup() { _factory = new MockRepository(MockBehavior.Strict); _clipboard = MockObjectFactory.CreateClipboardDevice(_factory); _fileName = null; _rawMap = VimUtil.CreateRegisterMap(_clipboard.Object, () => _fileName); _map = _rawMap; }
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; }