Ejemplo n.º 1
0
 public void SetUp(bool insertMode)
 {
     _factory = new MockRepository(MockBehavior.Strict);
     _factory.DefaultValue = DefaultValue.Mock;
     _textView             = EditorUtil.CreateView();
     _vim            = _factory.Create <IVim>(MockBehavior.Loose);
     _editorOptions  = _factory.Create <IEditorOptions>(MockBehavior.Loose);
     _globalSettings = _factory.Create <IVimGlobalSettings>();
     _localSettings  = _factory.Create <IVimLocalSettings>();
     _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
     _textChangeTracker = _factory.Create <ITextChangeTracker>();
     _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption <TextChange> .None);
     _undoRedoOperations = _factory.Create <IUndoRedoOperations>();
     _data = MockObjectFactory.CreateVimBuffer(
         _textView,
         settings: _localSettings.Object,
         vim: _vim.Object,
         factory: _factory);
     _operations = _factory.Create <ICommonOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_factory.Create <IEditorOperations>().Object);
     _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);
     _modeRaw = new Vim.Modes.Insert.InsertMode(
         _data.Object,
         _operations.Object,
         _broker.Object,
         _editorOptions.Object,
         _undoRedoOperations.Object,
         _textChangeTracker.Object,
         _isReplace: !insertMode);
     _mode = _modeRaw;
 }
Ejemplo n.º 2
0
        private 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 = _factory.Create <IUndoRedoOperations>();
            _wordCompletionSessionFactoryService = _factory.Create <IWordCompletionSessionFactoryService>();

            var localSettings = new LocalSettings(Vim.GlobalSettings);

            _vimBuffer = MockObjectFactory.CreateVimBuffer(
                _textView,
                localSettings: localSettings,
                vim: _vim.Object,
                factory: _factory);
            _vimBuffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Insert);
            _operations = _factory.Create <ICommonOperations>();
            _operations.SetupGet(x => x.EditorOperations).Returns(EditorUtil.FactoryService.EditorOperationsFactory.GetEditorOperations(_textView));
            _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>();

            // 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.IsKeyDown(It.IsAny <VimKey>())).Returns(false);

            _modeRaw = new Vim.Modes.Insert.InsertMode(
                _vimBuffer.Object,
                _operations.Object,
                _broker.Object,
                _editorOptions.Object,
                _undoRedoOperations.Object,
                _textChangeTracker.Object,
                _insertUtil.Object,
                !insertMode,
                _keyboardDevice.Object,
                _mouseDevice.Object,
                EditorUtil.FactoryService.WordUtilFactory.GetWordUtil(_textView.TextBuffer),
                _wordCompletionSessionFactoryService.Object);
            _mode             = _modeRaw;
            _mode.CommandRan += (sender, e) => { _lastCommandRan = e; };
        }
Ejemplo n.º 3
0
 public void CreateBuffer(params string[] lines)
 {
     _view = Utils.EditorUtil.CreateView(lines);
     _host = new Mock<IVimHost>(MockBehavior.Strict);
     _buffer = _view.TextBuffer;
     _data = Utils.MockObjectFactory.CreateVimBuffer(
         _view,
         vim: Utils.MockObjectFactory.CreateVim(host : _host.Object).Object);
     _operations = new Mock<ICommonOperations>(MockBehavior.Strict);
     _broker = new Mock<ICompletionWindowBroker>(MockBehavior.Strict);
     _modeRaw = new Vim.Modes.Insert.InsertMode(Tuple.Create<IVimBuffer,ICommonOperations,ICompletionWindowBroker>(_data.Object,_operations.Object,_broker.Object));
     _mode = _modeRaw;
 }
Ejemplo n.º 4
0
 public void CreateBuffer(params string[] lines)
 {
     _view = Utils.EditorUtil.CreateView(lines);
     _buffer = _view.TextBuffer;
     _vim = new Mock<IVim>();
     _globalSettings = new Mock<IVimGlobalSettings>(MockBehavior.Strict);
     _localSettings = new Mock<IVimLocalSettings>(MockBehavior.Strict);
     _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
     _data = Utils.MockObjectFactory.CreateVimBuffer(
         _view,
         settings:_localSettings.Object,
         vim:_vim.Object);
     _operations = new Mock<ICommonOperations>(MockBehavior.Strict);
     _broker = new Mock<IDisplayWindowBroker>(MockBehavior.Strict);
     _modeRaw = new Vim.Modes.Insert.InsertMode(Tuple.Create<IVimBuffer,ICommonOperations,IDisplayWindowBroker>(_data.Object,_operations.Object,_broker.Object));
     _mode = _modeRaw;
 }
Ejemplo n.º 5
0
 public void SetUp(bool insertMode)
 {
     _factory = new MockRepository(MockBehavior.Strict);
     _factory.DefaultValue = DefaultValue.Mock;
     _textView = _factory.Create<ITextView>();
     _vim = _factory.Create<IVim>(MockBehavior.Loose);
     _editorOptions = _factory.Create<IEditorOptions>(MockBehavior.Loose);
     _globalSettings = _factory.Create<IVimGlobalSettings>();
     _localSettings = _factory.Create<IVimLocalSettings>();
     _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
     _data = MockObjectFactory.CreateVimBuffer(
         _textView.Object,
         settings: _localSettings.Object,
         vim: _vim.Object,
         factory: _factory);
     _operations = _factory.Create<ICommonOperations>();
     _broker = _factory.Create<IDisplayWindowBroker>();
     _modeRaw = new Vim.Modes.Insert.InsertMode(_data.Object, _operations.Object, _broker.Object, _editorOptions.Object, _isReplace: !insertMode);
     _mode = _modeRaw;
 }
Ejemplo n.º 6
0
 public void SetUp(bool insertMode)
 {
     _factory = new MockRepository(MockBehavior.Strict);
     _factory.DefaultValue = DefaultValue.Mock;
     _textView = EditorUtil.CreateView();
     _vim = _factory.Create<IVim>(MockBehavior.Loose);
     _editorOptions = _factory.Create<IEditorOptions>(MockBehavior.Loose);
     _globalSettings = _factory.Create<IVimGlobalSettings>();
     _localSettings = _factory.Create<IVimLocalSettings>();
     _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
     _textChangeTracker = _factory.Create<ITextChangeTracker>();
     _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption<TextChange>.None);
     _undoRedoOperations = _factory.Create<IUndoRedoOperations>();
     _data = MockObjectFactory.CreateVimBuffer(
         _textView,
         settings: _localSettings.Object,
         vim: _vim.Object,
         factory: _factory);
     _operations = _factory.Create<ICommonOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_factory.Create<IEditorOperations>().Object);
     _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);
     _modeRaw = new Vim.Modes.Insert.InsertMode(
         _data.Object,
         _operations.Object,
         _broker.Object,
         _editorOptions.Object,
         _undoRedoOperations.Object,
         _textChangeTracker.Object,
         _isReplace: !insertMode);
     _mode = _modeRaw;
 }
Ejemplo n.º 7
0
        private void Create(bool insertMode, params string[] lines)
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _factory.DefaultValue = DefaultValue.Mock;
            _textView = EditorUtil.CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vim = _factory.Create<IVim>(MockBehavior.Loose);
            _editorOptions = _factory.Create<IEditorOptions>(MockBehavior.Loose);
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _localSettings = _factory.Create<IVimLocalSettings>();
            _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
            _textChangeTracker = _factory.Create<ITextChangeTracker>(MockBehavior.Loose);
            _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption<TextChange>.None);
            _undoRedoOperations = _factory.Create<IUndoRedoOperations>();
            _wordCompletionSessionFactoryService = _factory.Create<IWordCompletionSessionFactoryService>();

            _vimBuffer = MockObjectFactory.CreateVimBuffer(
                _textView,
                localSettings: _localSettings.Object,
                vim: _vim.Object,
                factory: _factory);
            _operations = _factory.Create<ICommonOperations>();
            _operations.SetupGet(x => x.EditorOperations).Returns(EditorUtil.FactoryService.EditorOperationsFactory.GetEditorOperations(_textView));
            _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>();

            // 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.IsKeyDown(It.IsAny<VimKey>())).Returns(false);

            _modeRaw = new Vim.Modes.Insert.InsertMode(
                _vimBuffer.Object,
                _operations.Object,
                _broker.Object,
                _editorOptions.Object,
                _undoRedoOperations.Object,
                _textChangeTracker.Object,
                _insertUtil.Object,
                !insertMode,
                _keyboardDevice.Object,
                _mouseDevice.Object,
                EditorUtil.FactoryService.WordUtilFactory.GetWordUtil(_textView.TextBuffer),
                _wordCompletionSessionFactoryService.Object);
            _mode = _modeRaw;
            _mode.CommandRan += (sender, e) => { _lastCommandRan = e; };
        }