Пример #1
0
        protected CommandMarginControllerTest()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _marginControl = new CommandMarginControl();
            _marginControl.CommandLineTextBox.Text = String.Empty;

            _search = _factory.Create<IIncrementalSearch>();
            _search.SetupGet(x => x.InSearch).Returns(false);
            _search.SetupGet(x => x.InPasteWait).Returns(false);
            _vimBuffer = new MockVimBuffer();
            _vimBuffer.IncrementalSearchImpl = _search.Object;
            _vimBuffer.VimImpl = MockObjectFactory.CreateVim(factory: _factory).Object;
            _vimBuffer.CommandModeImpl = _factory.Create<ICommandMode>(MockBehavior.Loose).Object;
            var textBuffer = CreateTextBuffer(new []{""});
            _vimBuffer.TextViewImpl = TextEditorFactoryService.CreateTextView(textBuffer);

            Mock<IVimGlobalSettings> globalSettings = new Mock<IVimGlobalSettings>();
            _vimBuffer.GlobalSettingsImpl = globalSettings.Object;

            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,
                VimEditorHost.EditorFormatMapService.GetEditorFormatMap(_vimBuffer.TextView),
                VimEditorHost.ClassificationFormatMapService.GetClassificationFormatMap(_vimBuffer.TextView));
        }
Пример #2
0
 public void BufferLifetime1()
 {
     var textView = EditorUtil.CreateView("foo");
     var vimBuffer = new MockVimBuffer() { TextBufferImpl = textView.TextBuffer, TextViewImpl = textView};
     _mapListener.VimBufferCreated(vimBuffer);
     _map.SetLocalMark(new SnapshotPoint(textView.TextSnapshot, 0), 'c');
     vimBuffer.RaiseClosed();
     Assert.IsTrue(_map.GetLocalMark(textView.TextBuffer, 'c').IsNone());
 }
Пример #3
0
 public void ActiveBuffer3()
 {
     var view = new Mock<IWpfTextView>(MockBehavior.Strict);
     var buffer = new MockVimBuffer();
     _factory.Setup(x => x.CreateBuffer(_vim, view.Object)).Returns(buffer);
     var ret = _vim.CreateBuffer(view.Object);
     buffer.RaiseKeyInputStart(KeyInputUtil.CharToKeyInput('c'));
     buffer.RaiseKeyInputEnd(KeyInputUtil.CharToKeyInput('c'));
     Assert.IsTrue(_vim.ActiveBuffer.IsNone());
 }
        public CommandMarginControllerTest()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _search = _factory.Create<IIncrementalSearch>();
            _search.SetupGet(x => x.InSearch).Returns(false);
            _vimBuffer = new MockVimBuffer();
            _vimBuffer.IncrementalSearchImpl = _search.Object;
            _vimBuffer.VimImpl = MockObjectFactory.CreateVim(factory: _factory).Object;
            _marginControl = new CommandMarginControl();
            _marginControl.StatusLine = String.Empty;

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

            _controller = new CommandMarginController(
                _vimBuffer,
                _marginControl,
                editorFormatMap.Object,
                new List<Lazy<IOptionsProviderFactory>>());
        }
 public void Setup()
 {
     _factory = new MockRepository(MockBehavior.Strict);
     _search = _factory.Create<IIncrementalSearch>();
     _buffer = new MockVimBuffer();
     _buffer.IncrementalSearchImpl = _search.Object;
     _buffer.VimImpl = MockObjectFactory.CreateVim(factory: _factory).Object;
     _marginControl = new CommandMarginControl();
     _marginControl.StatusLine = String.Empty;
     _controller = new CommandMarginController(
         _buffer,
         _marginControl,
         new List<Lazy<IOptionsProviderFactory>>());
 }
Пример #6
0
 protected void Create(params string[] lines)
 {
     _textBuffer = EditorUtil.CreateBuffer(lines);
     _factory = new MockRepository(MockBehavior.Loose);
     _textCaret = _factory.Create<ITextCaret>();
     _textView = _factory.Create<ITextView>();
     _textView.SetupGet(x => x.Caret).Returns(_textCaret.Object);
     _textView.SetupGet(x => x.HasAggregateFocus).Returns(true);
     _mouse = _factory.Create<IMouseDevice>();
     _keyboard = _factory.Create<IKeyboardDevice>();
     _vimBuffer = new MockVimBuffer()
     {
         TextViewImpl = _textView.Object,
         TextBufferImpl = _textBuffer
     };
     _trackerRaw = new TextChangeTracker(_vimBuffer, _keyboard.Object, _mouse.Object);
     _tracker = _trackerRaw;
     _tracker.ChangeCompleted += (sender, data) => { _lastChange = data; };
 }
Пример #7
0
        private void CreateForText(params string[] lines)
        {
            _textBuffer = EditorUtil.CreateBuffer(lines);
            _textView = MockObjectFactory.CreateTextView(_textBuffer);
            _textView.SetupGet(x => x.HasAggregateFocus).Returns(true);

            _normalModeRunner = new MockCommandRunner();
            _normalMode = new MockNormalMode() { CommandRunnerImpl = _normalModeRunner };
            _buffer = new MockVimBuffer() { TextViewImpl = _textView.Object, TextBufferImpl = _textBuffer, NormalModeImpl = _normalMode };
            _textChangeTracker = new MockTextChangeTracker() { VimBufferImpl = _buffer };

            _factory = new MockRepository(MockBehavior.Loose);
            _factory.DefaultValue = DefaultValue.Mock;
            _textChangeTrackerFactory = _factory.Create<ITextChangeTrackerFactory>();
            _textChangeTrackerFactory.Setup(x => x.GetTextChangeTracker(_buffer)).Returns(_textChangeTracker);
            _buffer.VisualBlockModeImpl = _factory.Create<IVisualMode>().Object;
            _buffer.VisualCharacterModeImpl = _factory.Create<IVisualMode>().Object;
            _buffer.VisualLineModeImpl = _factory.Create<IVisualMode>().Object;
            _trackerRaw = new ChangeTracker(_textChangeTrackerFactory.Object);
            _tracker = _trackerRaw;
            _trackerRaw.OnVimBufferCreated(_buffer);
        }
            protected override IVimBuffer CreateVimBuffer()
            {
                _search = _factory.Create<IIncrementalSearch>();
                _search.SetupGet(x => x.InSearch).Returns(false);
                _vimBuffer = new MockVimBuffer();
                _vimBuffer.IncrementalSearchImpl = _search.Object;
                _vimBuffer.VimImpl = MockObjectFactory.CreateVim(factory: _factory).Object;
                _vimBuffer.CommandModeImpl = _factory.Create<ICommandMode>(MockBehavior.Loose).Object;

                return _vimBuffer;
            }
Пример #9
0
 private void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _buffer = _textView.TextBuffer;
     var vimBuffer = new MockVimBuffer() { TextViewImpl = _textView, TextBufferImpl = _textView.TextBuffer };
     _mapListener.VimBufferCreated(vimBuffer);
 }
Пример #10
0
 public void Setup()
 {
     _buffer = new MockVimBuffer();
     _marginControl = new CommandMarginControl();
     _marginControl.StatusLine = String.Empty;
     _controller = new CommandMarginController(
         _buffer,
         _marginControl,
         new List<Lazy<IOptionsProviderFactory>>());
 }