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);
        }
Exemplo n.º 2
0
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _unnamedRegister = Vim.RegisterMap.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _commandUtil = _factory.Create<ICommandUtil>();

            _globalSettings = Vim.GlobalSettings;

            var vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer);
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);
            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            motionUtil = motionUtil ?? new MotionUtil(vimBufferData, operations);
            var lineChangeTracker = new LineChangeTracker(vimBufferData);

            var capture = new MotionCapture(vimBufferData, _incrementalSearch.Object);
            var runner = new CommandRunner(
                _textView,
                Vim.RegisterMap,
                capture,
                vimBufferData.LocalSettings,
                _commandUtil.Object,
                vimBufferData.StatusUtil,
                VisualKind.Character,
                KeyRemapMode.Normal);
            _modeRaw = new NormalMode(
                vimBufferData,
                operations,
                motionUtil,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
Exemplo n.º 3
0
 public void TearDown()
 {
     _textView = null;
     _mode = null;
 }
Exemplo n.º 4
0
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = EditorUtil.CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _unnamedRegister = _map.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _editorOperations = _factory.Create<IEditorOperations>(MockBehavior.Loose);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _jumpList = _factory.Create<IJumpList>(MockBehavior.Strict);
            _statusUtil = _factory.Create<IStatusUtil>(MockBehavior.Strict);
            _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
            _host = _factory.Create<IVimHost>(MockBehavior.Loose);
            _commandUtil = _factory.Create<ICommandUtil>();
            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _vimData = new VimData();

            _globalSettings = new Vim.GlobalSettings();
            _localSettings = new LocalSettings(_globalSettings, EditorUtil.GetEditorOptions(_textView), _textView);
            motionUtil = motionUtil ?? VimUtil.CreateTextViewMotionUtil(
                _textView,
                new MarkMap(new TrackingLineColumnService()),
                _localSettings);
            _buffer = MockObjectFactory.CreateVimBuffer(
                _textView,
                "test",
                MockObjectFactory.CreateVim(_map, host: _host.Object, vimData: _vimData).Object,
                _jumpList.Object,
                incrementalSearch: _incrementalSearch.Object,
                motionUtil: motionUtil,
                settings: _localSettings);
            _operations = _factory.Create<ICommonOperations>(MockBehavior.Strict);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_textView);

            var capture = new MotionCapture(
                _host.Object,
                _textView,
                _incrementalSearch.Object,
                new LocalSettings(new GlobalSettings(), EditorUtil.GetEditorOptions(_textView), _textView));
            var runner = new CommandRunner(_textView, _map, capture, _commandUtil.Object, _statusUtil.Object, VisualKind.Character);
            _modeRaw = new NormalMode(
                _buffer.Object,
                _operations.Object,
                _statusUtil.Object,
                _displayWindowBroker.Object,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
Exemplo n.º 5
0
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _unnamedRegister = Vim.RegisterMap.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _commandUtil = _factory.Create<ICommandUtil>();
            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _globalSettings = Vim.GlobalSettings;

            var vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer);
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);
            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            motionUtil = motionUtil ?? new MotionUtil(vimBufferData);

            var capture = new MotionCapture(vimBufferData, _incrementalSearch.Object);
            var runner = new CommandRunner(
                _textView,
                Vim.RegisterMap,
                capture,
                _commandUtil.Object,
                vimBufferData.StatusUtil,
                VisualKind.Character);
            _modeRaw = new NormalMode(
                vimBufferData,
                operations,
                motionUtil,
                _displayWindowBroker.Object,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
Exemplo n.º 6
0
 public void Create(params string[] lines)
 {
     _view = Utils.EditorUtil.CreateView(lines);
     _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
     _map = new RegisterMap();
     _editorOperations = new Mock<IEditorOperations>();
     _incrementalSearch = new Mock<IIncrementalSearch>(MockBehavior.Strict);
     _jumpList = new Mock<IJumpList>(MockBehavior.Strict);
     _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
     _changeTracker = new Mock<IChangeTracker>(MockBehavior.Strict);
     _displayWindowBroker = new Mock<IDisplayWindowBroker>(MockBehavior.Strict);
     _displayWindowBroker.SetupGet(x => x.IsSmartTagWindowActive).Returns(false);
     _bufferData = MockFactory.CreateVimBuffer(
         _view,
         "test",
         MockFactory.CreateVim(_map,changeTracker:_changeTracker.Object).Object,
         _jumpList.Object);
     _operations = new Mock<IOperations>(MockBehavior.Strict);
     _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
     _operations.SetupGet(x => x.TextView).Returns(_view);
     _modeRaw = new Vim.Modes.Normal.NormalMode(Tuple.Create(_bufferData.Object, _operations.Object, _incrementalSearch.Object, _statusUtil.Object, _displayWindowBroker.Object));
     _mode = _modeRaw;
     _mode.OnEnter();
 }
Exemplo n.º 7
0
 public void TearDown()
 {
     _view = null;
     _mode = null;
 }
Exemplo n.º 8
0
        public void CreateCore(ITextViewMotionUtil motionUtil, params string[] lines)
        {
            _view = EditorUtil.CreateView(lines);
            _view.Caret.MoveTo(new SnapshotPoint(_view.TextSnapshot, 0));
            _map = new RegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _editorOperations = new Mock<IEditorOperations>();
            _incrementalSearch = new Mock<IIncrementalSearch>(MockBehavior.Strict);
            _jumpList = new Mock<IJumpList>(MockBehavior.Strict);
            _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
            _changeTracker = new Mock<IChangeTracker>(MockBehavior.Strict);
            _foldManager = new Mock<IFoldManager>(MockBehavior.Strict);
            _visualSpanCalculator = new Mock<IVisualSpanCalculator>(MockBehavior.Strict);
            _host = new Mock<IVimHost>(MockBehavior.Loose);
            _displayWindowBroker = new Mock<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _bufferData = MockRepository.CreateVimBuffer(
                _view,
                "test",
                MockRepository.CreateVim(_map, changeTracker: _changeTracker.Object, host: _host.Object).Object,
                _jumpList.Object);
            _operations = new Mock<IOperations>(MockBehavior.Strict);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_view);
            _operations.SetupGet(x => x.FoldManager).Returns(_foldManager.Object);

            motionUtil = motionUtil ?? new TextViewMotionUtil(_view, new Vim.LocalSettings(
                    new Vim.GlobalSettings(),
                    _view));
            var capture = new MotionCapture(_host.Object, _view, motionUtil, new MotionCaptureGlobalData());
            var runner = new CommandRunner(_view, _map, (IMotionCapture)capture, _statusUtil.Object);
            _modeRaw = new Vim.Modes.Normal.NormalMode(
                _bufferData.Object,
                _operations.Object,
                _incrementalSearch.Object,
                _statusUtil.Object,
                _displayWindowBroker.Object,
                (ICommandRunner)runner,
                (IMotionCapture)capture,
                _visualSpanCalculator.Object);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }