예제 #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
파일: VimTest.cs 프로젝트: otf/VsVim
 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>>());
 }