コード例 #1
0
ファイル: VimKeyProcessorTest.cs プロジェクト: Kazark/VsVim
 protected static KeyEventArgs CreateKeyEventArgs(
     Key key,
     ModifierKeys modKeys = ModifierKeys.None)
 {
     var device = new MockKeyboardDevice(InputManager.Current) { ModifierKeysImpl = modKeys };
     return device.CreateKeyEventArgs(key, modKeys);
 }
コード例 #2
0
        protected FallbackKeyProcessorTest(bool useVimBuffer = false)
        {
            _keyboardDevice = new MockKeyboardDevice();
            _commands = new Mock<Commands>(MockBehavior.Strict);
            _dte = new Mock<_DTE>(MockBehavior.Loose);
            _dte.SetupGet(x => x.Commands).Returns(_commands.Object);
            _vsShell = new Mock<IVsShell>(MockBehavior.Loose);
            _removedBindingList = new List<CommandKeyBinding>();
            _vimApplicationSettings = new Mock<IVimApplicationSettings>(MockBehavior.Loose);
            _vimApplicationSettings
                .SetupGet(x => x.RemovedBindings)
                .Returns(() => _removedBindingList.AsReadOnly());

            var textView = CreateTextView("");
            _vimBuffer = useVimBuffer
                ? Vim.GetOrCreateVimBuffer(textView)
                : null;
            _keyProcessor = new FallbackKeyProcessor(
                _vsShell.Object,
                _dte.Object,
                CompositionContainer.GetExportedValue<IKeyUtil>(),
                _vimApplicationSettings.Object,
                textView,
                _vimBuffer,
                new ScopeData());
        }
コード例 #3
0
        protected virtual void Create(params string[] lines)
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _marginControl = new CommandMarginControl();
            _marginControl.CommandLineTextBox.Text = String.Empty;
            _vimBuffer = CreateVimBuffer(lines);
            _textBuffer = _vimBuffer.TextBuffer;
            _textView = _vimBuffer.TextView;
            _keyboardDevice = new MockKeyboardDevice();

            var parentVisualElement = _factory.Create<FrameworkElement>();

            _controller = new CommandMarginController(
                _vimBuffer,
                parentVisualElement.Object,
                _marginControl,
                VimEditorHost.EditorFormatMapService.GetEditorFormatMap(_vimBuffer.TextView),
                VimEditorHost.ClassificationFormatMapService.GetClassificationFormatMap(_vimBuffer.TextView));
        }
コード例 #4
0
        protected override VimKeyProcessor CreateKeyProcessor()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _wpfTextView = CreateTextView();
            _mockAdapter = new MockAdapter();
            _editorAdaptersFactoryService = _factory.Create<IVsEditorAdaptersFactoryService>();
            _editorAdaptersFactoryService.Setup(x => x.GetViewAdapter(_wpfTextView)).Returns(_mockAdapter);

            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);
            _vsAdapter.SetupGet(x => x.EditorAdapter).Returns(_editorAdaptersFactoryService.Object);
            _vsAdapter.Setup(x => x.IsReadOnly(_wpfTextView)).Returns(false);
            _mockVimBuffer = MockObjectFactory.CreateVimBuffer(_wpfTextView);
            _mockVimBuffer.Setup(x => x.CanProcess(It.IsAny<KeyInput>())).Returns(true);
            _mockVimBuffer.Setup(x => x.Process(It.IsAny<KeyInput>())).Returns(ProcessResult.NewHandled(ModeSwitch.NoSwitch));
            _mockVimBuffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal);
            _bufferCoordinator = new VimBufferCoordinator(_mockVimBuffer.Object);
            _device = new MockKeyboardDevice();
            return new VsKeyProcessor(_vsAdapter.Object, _bufferCoordinator, KeyUtil);
        }
コード例 #5
0
        protected virtual void Create(params string[] lines)
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _marginControl = new CommandMarginControl();
            _marginControl.StatusLine = String.Empty;
            _vimBuffer = CreateVimBuffer(lines);
            _textBuffer = _vimBuffer.TextBuffer;
            _textView = _vimBuffer.TextView;
            _keyboardDevice = new MockKeyboardDevice();

            var editorFormatMap = _factory.Create<IEditorFormatMap>(MockBehavior.Loose);
            editorFormatMap.Setup(x => x.GetProperties(It.IsAny<string>())).Returns(new ResourceDictionary());

            var parentVisualElement = _factory.Create<FrameworkElement>();

            _controller = new CommandMarginController(
                _vimBuffer,
                parentVisualElement.Object,
                _marginControl,
                editorFormatMap.Object,
                new List<Lazy<IOptionsProviderFactory>>());
        }
コード例 #6
0
 protected override void Setup(string languageId)
 {
     base.Setup(languageId);
     _factory = new MockRepository(MockBehavior.Strict);
     _textBuffer = _factory.Create<ITextBuffer>();
     _adapter = _factory.Create<IVsAdapter>();
     _adapter.Setup(x => x.IsReadOnly(_textBuffer.Object)).Returns(false);
     _buffer = MockObjectFactory.CreateVimBuffer(_textBuffer.Object);
     _vsProcessor = new VsKeyProcessor(_adapter.Object, _buffer.Object);
     _processor = _vsProcessor;
     _device = new MockKeyboardDevice();
 }
コード例 #7
0
ファイル: VsKeyProcessorTest.cs プロジェクト: bajtos/VsVim
 protected override void Setup(string languageId)
 {
     base.Setup(languageId);
     _factory = new MockRepository(MockBehavior.Strict);
     _textBuffer = _factory.Create<ITextBuffer>();
     _vsAdapter = _factory.Create<IVsAdapter>();
     _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);
     _buffer = MockObjectFactory.CreateVimBuffer(_textBuffer.Object);
     _buffer.Setup(x => x.CanProcess(It.IsAny<KeyInput>())).Returns(true);
     _buffer.Setup(x => x.Process(It.IsAny<KeyInput>())).Returns(ProcessResult.NewHandled(ModeSwitch.NoSwitch));
     _buffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal);
     _bufferCoordinator = new VimBufferCoordinator(_buffer.Object);
     _vsProcessor = new VsKeyProcessor(_vsAdapter.Object, _bufferCoordinator);
     _processor = _vsProcessor;
     _device = new MockKeyboardDevice();
 }