Пример #1
0
        public CommandMarginUtilTest()
        {
            _factory = new MockRepository(MockBehavior.Strict);

            _search = _factory.Create <IIncrementalSearch>();
            _search.SetupGet(x => x.HasActiveSession).Returns(false);

            _normalMode = _factory.Create <INormalMode>();
            _normalMode.SetupGet(x => x.Command).Returns(string.Empty);
            _normalRunner = _factory.Create <ICommandRunner>();
            _normalMode.SetupGet(x => x.CommandRunner).Returns(_normalRunner.Object);
            _normalRunner.SetupGet(x => x.Inputs).Returns(FSharpList <KeyInput> .Empty);

            _visualMode   = _factory.Create <IVisualMode>();
            _visualRunner = _factory.Create <ICommandRunner>();
            _visualMode.SetupGet(x => x.CommandRunner).Returns(_visualRunner.Object);
            _visualRunner.SetupGet(x => x.Inputs).Returns(FSharpList <KeyInput> .Empty);

            _vimBuffer = new MockVimBuffer
            {
                IncrementalSearchImpl = _search.Object,
                VimImpl               = MockObjectFactory.CreateVim(factory: _factory).Object,
                NormalModeImpl        = _normalMode.Object,
                BufferedKeyInputsImpl = FSharpList <KeyInput> .Empty
            };
        }
Пример #2
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));
        }
Пример #3
0
        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;
            _vimBuffer.CommandModeImpl = _factory.Create <ICommandMode>(MockBehavior.Loose).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());

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

            _controller = new CommandMarginController(
                _vimBuffer,
                parentVisualElement.Object,
                _marginControl,
                editorFormatMap.Object,
                new List <Lazy <IOptionsProviderFactory> >());
        }
Пример #4
0
            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);
            }
Пример #5
0
        private void Create(params string[] lines)
        {
            _textView   = EditorUtil.CreateView(lines);
            _textBuffer = _textView.TextBuffer;
            var vimBuffer = new MockVimBuffer()
            {
                TextViewImpl = _textView, TextBufferImpl = _textView.TextBuffer
            };

            _mapListener.VimBufferCreated(vimBuffer);
        }
Пример #6
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());
        }
Пример #7
0
 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> >());
 }
Пример #8
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; };
 }
Пример #9
0
        protected CommandMarginControllerTest()
        {
            _factory       = new MockRepository(MockBehavior.Strict);
            _marginControl = new CommandMarginControl();
            _marginControl.CommandLineTextBox.Text = string.Empty;

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

            _vimBuffer.TextViewImpl = TextEditorFactoryService.CreateTextView(textBuffer);

            var vimBufferData = CreateVimBufferData(_vimBuffer.TextView);

            _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>();

            _clipboardDevice = (TestableClipboardDevice)CompositionContainer.GetExportedValue <IClipboardDevice>();

            _controller = new CommandMarginController(
                _vimBuffer,
                parentVisualElement.Object,
                _marginControl,
                VimEditorHost.EditorFormatMapService.GetEditorFormatMap(_vimBuffer.TextView),
                VimEditorHost.ClassificationFormatMapService.GetClassificationFormatMap(_vimBuffer.TextView),
                CommonOperationsFactory.GetCommonOperations(vimBufferData),
                _clipboardDevice,
                false);
        }
 public void Setup()
 {
     _buffer = new MockVimBuffer();
     _marginControl = new CommandMarginControl();
     _marginControl.StatusLine = String.Empty;
     _controller = new CommandMarginController(
         _buffer,
         _marginControl,
         new List<Lazy<IOptionsProviderFactory>>());
 }
Пример #11
0
        private void CreateForText(params string[] lines)
        {
            _textBuffer = Utils.EditorUtil.CreateBuffer(lines);
            _textView = Mock.MockObjectFactory.CreateTextView(_textBuffer);
            _textView.SetupGet(x => x.HasAggregateFocus).Returns(true);
            _buffer = new MockVimBuffer();
            _buffer.TextViewImpl = _textView.Object;
            _buffer.TextBufferImpl = _textBuffer;

            var factory = new MockFactory(MockBehavior.Loose);
            factory.DefaultValue = DefaultValue.Mock;
            _buffer.NormalModeImpl = factory.Create<INormalMode>().Object;
            _buffer.VisualBlockModeImpl = factory.Create<IVisualMode>().Object;
            _buffer.VisualCharacterModeImpl = factory.Create<IVisualMode>().Object;
            _buffer.VisualLineModeImpl = factory.Create<IVisualMode>().Object;
            _trackerRaw = new ChangeTracker();
            _tracker = _trackerRaw;
            _trackerRaw.OnVimBufferCreated(_buffer);
        }