Example #1
0
        public static Mock <IVimBuffer> CreateVimBuffer(
            ITextView textView,
            string name                           = null,
            IVim vim                              = null,
            IJumpList jumpList                    = null,
            IVimLocalSettings settings            = null,
            IIncrementalSearch incrementalSearch  = null,
            IMotionUtil motionUtil                = null,
            ITextStructureNavigator wordNavigator = null,
            MockRepository factory                = null)
        {
            factory       = factory ?? new MockRepository(MockBehavior.Strict);
            name          = name ?? "test";
            vim           = vim ?? CreateVim().Object;
            jumpList      = jumpList ?? (factory.Create <IJumpList>().Object);
            motionUtil    = motionUtil ?? factory.Create <IMotionUtil>().Object;
            wordNavigator = wordNavigator ?? factory.Create <ITextStructureNavigator>().Object;
            settings      = settings ?? new LocalSettings(vim.Settings, FSharpOption.Create(textView));
            var mock = factory.Create <IVimBuffer>();

            mock.SetupGet(x => x.TextView).Returns(textView);
            mock.SetupGet(x => x.MotionUtil).Returns(motionUtil);
            mock.SetupGet(x => x.TextBuffer).Returns(() => textView.TextBuffer);
            mock.SetupGet(x => x.TextSnapshot).Returns(() => textView.TextSnapshot);
            mock.SetupGet(x => x.Name).Returns(name);
            mock.SetupGet(x => x.Settings).Returns(settings);
            mock.SetupGet(x => x.MarkMap).Returns(vim.MarkMap);
            mock.SetupGet(x => x.RegisterMap).Returns(vim.RegisterMap);
            mock.SetupGet(x => x.JumpList).Returns(jumpList);
            mock.SetupGet(x => x.Vim).Returns(vim);
            mock.SetupGet(x => x.VimData).Returns(vim.VimData);
            mock.SetupGet(x => x.IncrementalSearch).Returns(incrementalSearch);
            mock.SetupGet(x => x.WordNavigator).Returns(wordNavigator);
            return(mock);
        }
Example #2
0
 public void Create(params string[] lines)
 {
     _textBuffer = EditorUtil.CreateTextBuffer(lines);
     _trackingLineColumnService = new TrackingLineColumnService();
     _jumpListRaw = new JumpList(_trackingLineColumnService);
     _jumpList = _jumpListRaw;
 }
Example #3
0
 public void Create(params string[] lines)
 {
     _textBuffer = EditorUtil.CreateBuffer(lines);
     _trackingLineColumnService = new TrackingLineColumnService();
     _jumpListRaw = new JumpList(_trackingLineColumnService);
     _jumpList    = _jumpListRaw;
 }
Example #4
0
 private void Create(ITextView textView, IEditorOptions editorOptions = null)
 {
     _textView = textView;
     _textBuffer = textView.TextBuffer;
     _snapshot = _textBuffer.CurrentSnapshot;
     _textBuffer.Changed += delegate { _snapshot = _textBuffer.CurrentSnapshot; };
     _globalSettings = new Vim.GlobalSettings();
     _localSettings = new LocalSettings(_globalSettings, FSharpOption.CreateForReference(editorOptions), FSharpOption.CreateForReference(textView));
     _markMap = new MarkMap(new TrackingLineColumnService());
     _vimData = new VimData();
     _search = VimUtil.CreateSearchService(_globalSettings);
     _jumpList = VimUtil.CreateJumpList();
     _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
     _navigator = VimUtil.CreateTextStructureNavigator(_textView, WordKind.NormalWord);
     _motionUtil = new MotionUtil(
         _textView,
         _markMap,
         _localSettings,
         _search,
         _navigator,
         _jumpList,
         _statusUtil.Object,
         VimUtil.GetWordUtil(textView),
         _vimData);
 }
Example #5
0
 /// <summary>
 /// This is not technically a Mock but often we want to create it with mocked
 /// backing values
 /// </summary>
 /// <returns></returns>
 public static IVimBufferData CreateVimBufferData(
     IVimTextBuffer vimTextBuffer,
     ITextView textView,
     IJumpList jumpList     = null,
     IStatusUtil statusUtil = null,
     IUndoRedoOperations undoRedoOperations = null,
     IVimWindowSettings windowSettings      = null,
     IWordUtil wordUtil     = null,
     MockRepository factory = null)
 {
     factory            = factory ?? new MockRepository(MockBehavior.Strict);
     statusUtil         = statusUtil ?? factory.Create <IStatusUtil>().Object;
     undoRedoOperations = undoRedoOperations ?? factory.Create <IUndoRedoOperations>().Object;
     jumpList           = jumpList ?? factory.Create <IJumpList>().Object;
     wordUtil           = wordUtil ?? factory.Create <IWordUtil>().Object;
     windowSettings     = windowSettings ?? factory.Create <IVimWindowSettings>().Object;
     return(new VimBufferData(
                vimTextBuffer,
                textView,
                windowSettings,
                jumpList,
                statusUtil,
                undoRedoOperations,
                wordUtil));
 }
Example #6
0
 internal static IMotionUtil CreateTextViewMotionUtil(
     ITextView textView,
     IMarkMap markMap                  = null,
     IVimLocalSettings settings        = null,
     ISearchService search             = null,
     ITextStructureNavigator navigator = null,
     IJumpList jumpList                = null,
     IStatusUtil statusUtil            = null,
     IVimData vimData                  = null)
 {
     markMap    = markMap ?? new MarkMap(new TrackingLineColumnService());
     settings   = settings ?? new LocalSettings(new GlobalSettings(), textView);
     search     = search ?? CreateSearchService(settings.GlobalSettings);
     navigator  = navigator ?? CreateTextStructureNavigator(textView.TextBuffer);
     jumpList   = jumpList ?? CreateJumpList();
     statusUtil = statusUtil ?? new StatusUtil();
     vimData    = vimData ?? new VimData();
     return(new MotionUtil(
                textView,
                markMap,
                settings,
                search,
                navigator,
                jumpList,
                statusUtil,
                vimData));
 }
Example #7
0
 /// <summary>
 /// This is not technically a Mock but often we want to create it with mocked
 /// backing values
 /// </summary>
 /// <returns></returns>
 public static IVimBufferData CreateVimBufferData(
     IVimTextBuffer vimTextBuffer,
     ITextView textView,
     IJumpList jumpList                 = null,
     IStatusUtil statusUtil             = null,
     IVimWindowSettings windowSettings  = null,
     ICaretRegisterMap caretRegisterMap = null,
     ISelectionUtil selectionUtil       = null,
     MockRepository factory             = null)
 {
     factory          = factory ?? new MockRepository(MockBehavior.Strict);
     statusUtil       = statusUtil ?? factory.Create <IStatusUtil>().Object;
     jumpList         = jumpList ?? factory.Create <IJumpList>().Object;
     windowSettings   = windowSettings ?? factory.Create <IVimWindowSettings>().Object;
     caretRegisterMap = caretRegisterMap ?? factory.Create <ICaretRegisterMap>().Object;
     selectionUtil    = selectionUtil ?? new SingleSelectionUtil(textView);
     return(new VimBufferData(
                vimTextBuffer,
                textView,
                windowSettings,
                jumpList,
                statusUtil,
                selectionUtil,
                caretRegisterMap));
 }
Example #8
0
 private void Create(ITextView textView)
 {
     _textView = textView;
     _textBuffer = textView.TextBuffer;
     _buffer = _textView.TextBuffer;
     _snapshot = _buffer.CurrentSnapshot;
     _buffer.Changed += delegate { _snapshot = _buffer.CurrentSnapshot; };
     _globalSettings = new Vim.GlobalSettings();
     _localSettings = new LocalSettings(_globalSettings, _textView);
     _markMap = new MarkMap(new TrackingLineColumnService());
     _vimData = new VimData();
     _search = VimUtil.CreateSearchService(_globalSettings);
     _jumpList = VimUtil.CreateJumpList();
     _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
     _navigator = VimUtil.CreateTextStructureNavigator(_textView.TextBuffer);
     _motionUtil = new MotionUtil(
         _textView,
         _markMap,
         _localSettings,
         _search,
         _navigator,
         _jumpList,
         _statusUtil.Object,
         _vimData);
 }
Example #9
0
 public void Create(params string[] lines)
 {
     var textView = CreateTextView(lines);
     _textBuffer = textView.TextBuffer;
     _bufferTrackingService = new BufferTrackingService();
     _jumpListRaw = new JumpList(textView, _bufferTrackingService);
     _jumpList = _jumpListRaw;
 }
Example #10
0
        public void Create(params string[] lines)
        {
            var textView = CreateTextView(lines);

            _textBuffer            = textView.TextBuffer;
            _bufferTrackingService = new BufferTrackingService();
            _jumpListRaw           = new JumpList(textView, _bufferTrackingService);
            _jumpList = _jumpListRaw;
        }
Example #11
0
        internal static CommandUtil CreateCommandUtil(
            ITextView textView,
            ICommonOperations operations                     = null,
            IMotionUtil motionUtil                           = null,
            IStatusUtil statusUtil                           = null,
            IRegisterMap registerMap                         = null,
            IMarkMap markMap                                 = null,
            IVimData vimData                                 = null,
            IVimLocalSettings localSettings                  = null,
            IUndoRedoOperations undoRedOperations            = null,
            ISmartIndentationService smartIndentationService = null,
            IFoldManager foldManager                         = null,
            IVimHost vimHost                                 = null,
            IMacroRecorder recorder                          = null,
            ISearchService searchService                     = null,
            ITextStructureNavigator wordNavigator            = null,
            IJumpList jumpList                               = null)
        {
            statusUtil              = statusUtil ?? new StatusUtil();
            undoRedOperations       = undoRedOperations ?? VimUtil.CreateUndoRedoOperations(statusUtil);
            localSettings           = localSettings ?? new LocalSettings(new GlobalSettings());
            registerMap             = registerMap ?? CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            markMap                 = markMap ?? new MarkMap(new TrackingLineColumnService());
            vimData                 = vimData ?? new VimData();
            motionUtil              = motionUtil ?? CreateTextViewMotionUtil(textView, markMap: markMap, vimData: vimData, settings: localSettings);
            operations              = operations ?? CreateCommonOperations(textView, localSettings, vimData: vimData, statusUtil: statusUtil);
            smartIndentationService = smartIndentationService ?? CreateSmartIndentationService();
            foldManager             = foldManager ?? CreateFoldManager(textView.TextBuffer);
            searchService           = searchService ?? CreateSearchService(localSettings.GlobalSettings);
            wordNavigator           = wordNavigator ?? CreateTextStructureNavigator(textView.TextBuffer, WordKind.NormalWord);
            jumpList                = jumpList ?? CreateJumpList();
            vimHost                 = vimHost ?? new MockVimHost();
            var vim = MockObjectFactory.CreateVim(
                registerMap: registerMap,
                map: markMap,
                host: vimHost,
                vimData: vimData,
                recorder: recorder,
                searchService: searchService);
            var buffer = MockObjectFactory.CreateVimBuffer(
                textView: textView,
                settings: localSettings,
                motionUtil: motionUtil,
                vim: vim.Object,
                wordNavigator: wordNavigator,
                jumpList: jumpList);

            return(new CommandUtil(
                       buffer.Object,
                       operations,
                       statusUtil,
                       undoRedOperations,
                       smartIndentationService,
                       foldManager));
        }
Example #12
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     ITextView textView,
     IStatusUtil statusUtil            = null,
     IJumpList jumpList                = null,
     IVimWindowSettings windowSettings = null)
 {
     return(CreateVimBufferData(
                Vim.GetOrCreateVimTextBuffer(textView.TextBuffer),
                textView,
                statusUtil,
                jumpList,
                windowSettings));
 }
Example #13
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     ITextView textView,
     IStatusUtil statusUtil             = null,
     IJumpList jumpList                 = null,
     IVimWindowSettings windowSettings  = null,
     ICaretRegisterMap caretRegisterMap = null,
     ISelectionUtil selectionUtil       = null)
 {
     return(CreateVimBufferData(
                Vim.GetOrCreateVimTextBuffer(textView.TextBuffer),
                textView,
                statusUtil,
                jumpList,
                windowSettings,
                caretRegisterMap,
                selectionUtil));
 }
Example #14
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     IVimTextBuffer vimTextBuffer,
     ITextView textView,
     IStatusUtil statusUtil            = null,
     IJumpList jumpList                = null,
     IVimWindowSettings windowSettings = null)
 {
     jumpList       = jumpList ?? new JumpList(textView, BufferTrackingService);
     statusUtil     = statusUtil ?? new StatusUtil();
     windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings);
     return(new VimBufferData(
                vimTextBuffer,
                textView,
                windowSettings,
                jumpList,
                statusUtil));
 }
Example #15
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     ITextView textView,
     IStatusUtil statusUtil = null,
     IJumpList jumpList     = null,
     IUndoRedoOperations undoRedoOperations = null,
     IVimWindowSettings windowSettings      = null,
     IWordUtil wordUtil = null)
 {
     return(CreateVimBufferData(
                Vim.GetOrCreateVimTextBuffer(textView.TextBuffer),
                textView,
                statusUtil,
                jumpList,
                undoRedoOperations,
                windowSettings,
                wordUtil));
 }
Example #16
0
        public static Mock <IVimBuffer> CreateVimBuffer(
            ITextView textView,
            string name        = null,
            IVim vim           = null,
            IJumpList jumpList = null,
            IVimLocalSettings localSettings      = null,
            IIncrementalSearch incrementalSearch = null,
            IMotionUtil motionUtil = null,
            WordUtil wordUtil      = null,
            MockRepository factory = null)
        {
            factory       = factory ?? new MockRepository(MockBehavior.Strict);
            name          = name ?? "test";
            vim           = vim ?? CreateVim().Object;
            jumpList      = jumpList ?? (factory.Create <IJumpList>().Object);
            motionUtil    = motionUtil ?? factory.Create <IMotionUtil>().Object;
            localSettings = localSettings ?? new LocalSettings(vim.GlobalSettings);
            wordUtil      = wordUtil ?? new WordUtil(textView.TextBuffer, localSettings);
            var vimTextBuffer = CreateVimTextBuffer(
                textView.TextBuffer,
                localSettings: localSettings,
                vim: vim,
                wordUtil: wordUtil,
                factory: factory);
            var mock = factory.Create <IVimBuffer>();

            mock.SetupGet(x => x.TextView).Returns(textView);
            mock.SetupGet(x => x.MotionUtil).Returns(motionUtil);
            mock.SetupGet(x => x.TextBuffer).Returns(() => textView.TextBuffer);
            mock.SetupGet(x => x.TextSnapshot).Returns(() => textView.TextSnapshot);
            mock.SetupGet(x => x.Name).Returns(name);
            mock.SetupGet(x => x.LocalSettings).Returns(localSettings);
            mock.SetupGet(x => x.GlobalSettings).Returns(localSettings.GlobalSettings);
            mock.SetupGet(x => x.MarkMap).Returns(vim.MarkMap);
            mock.SetupGet(x => x.RegisterMap).Returns(vim.RegisterMap);
            mock.SetupGet(x => x.JumpList).Returns(jumpList);
            mock.SetupGet(x => x.Vim).Returns(vim);
            mock.SetupGet(x => x.VimData).Returns(vim.VimData);
            mock.SetupGet(x => x.IncrementalSearch).Returns(incrementalSearch);
            mock.SetupGet(x => x.WordNavigator).Returns(wordUtil.WordNavigator);
            mock.SetupGet(x => x.VimTextBuffer).Returns(vimTextBuffer.Object);
            return(mock);
        }
        protected virtual void Create(params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _vimBuffer.ErrorMessage +=
                (_, message) =>
                {
                    if (_assertOnErrorMessage)
                    {
                        throw new Exception("Error Message: " + message.Message);
                    }
                };
            _vimBuffer.WarningMessage +=
                (_, message) =>
                {
                    if (_assertOnWarningMessage)
                    {
                        throw new Exception("Warning Message: " + message.Message);
                    }
                };
            _vimBufferData = _vimBuffer.VimBufferData;
            _vimTextBuffer = _vimBuffer.VimTextBuffer;
            _normalMode = _vimBuffer.NormalMode;
            _keyMap = _vimBuffer.Vim.KeyMap;
            _localSettings = _vimBuffer.LocalSettings;
            _globalSettings = _localSettings.GlobalSettings;
            _windowSettings = _vimBuffer.WindowSettings;
            _jumpList = _vimBuffer.JumpList;
            _vimHost = (MockVimHost)_vimBuffer.Vim.VimHost;
            _vimHost.BeepCount = 0;
            _vimData = Vim.VimData;
            _foldManager = FoldManagerFactory.GetFoldManager(_textView);
            _clipboardDevice = (TestableClipboardDevice)CompositionContainer.GetExportedValue<IClipboardDevice>();

            // Many of the operations operate on both the visual and edit / text snapshot
            // simultaneously.  Ensure that our setup code is producing a proper IElisionSnapshot
            // for the Visual portion so we can root out any bad mixing of instances between
            // the two
            Assert.True(_textView.VisualSnapshot is IElisionSnapshot);
            Assert.True(_textView.VisualSnapshot != _textView.TextSnapshot);
        }
Example #18
0
        protected void Create(params string[] lines)
        {
            _vimHost = (MockVimHost)Vim.VimHost;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimTextBuffer = CreateVimTextBufferCore(_textBuffer);
            _localSettings = _vimTextBuffer.LocalSettings;

            var foldManager = CreateFoldManager(_textView);

            _factory = new MockRepository(MockBehavior.Loose);
            _statusUtil = _factory.Create<IStatusUtil>();
            _bulkOperations = new TestableBulkOperations();

            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView,
                statusUtil: _statusUtil.Object);
            _jumpList = vimBufferData.JumpList;
            _windowSettings = vimBufferData.WindowSettings;

            _vimData = Vim.VimData;
            _macroRecorder = Vim.MacroRecorder;
            _globalSettings = Vim.GlobalSettings;

            var operations = CreateCommonOperations(vimBufferData);
            var lineChangeTracker = new LineChangeTracker(vimBufferData);
            _motionUtil = new MotionUtil(vimBufferData, operations);
            _commandUtil = new CommandUtil(
                vimBufferData,
                _motionUtil,
                operations,
                foldManager,
                new InsertUtil(vimBufferData, _motionUtil, operations),
                _bulkOperations,
                MouseDevice,
                lineChangeTracker);

            var outliningManagerService = CompositionContainer.GetExportedValue<IOutliningManagerService>();
            _outliningManager = outliningManagerService.GetOutliningManager(_textView);
        }
Example #19
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     IVimTextBuffer vimTextBuffer,
     ITextView textView,
     IStatusUtil statusUtil = null,
     IJumpList jumpList     = null,
     IUndoRedoOperations undoRedoOperations = null,
     IVimWindowSettings windowSettings      = null,
     IWordUtil wordUtil = null)
 {
     jumpList           = jumpList ?? new JumpList(textView, _bufferTrackingService);
     statusUtil         = statusUtil ?? new StatusUtil();
     undoRedoOperations = undoRedoOperations ?? CreateUndoRedoOperations(statusUtil);
     windowSettings     = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings);
     wordUtil           = wordUtil ?? WordUtilFactory.GetWordUtil(vimTextBuffer.TextBuffer);
     return(new VimBufferData(
                vimTextBuffer,
                textView,
                windowSettings,
                jumpList,
                statusUtil,
                undoRedoOperations,
                wordUtil));
 }
Example #20
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     IVimTextBuffer vimTextBuffer,
     ITextView textView,
     IStatusUtil statusUtil             = null,
     IJumpList jumpList                 = null,
     IVimWindowSettings windowSettings  = null,
     ICaretRegisterMap caretRegisterMap = null,
     ISelectionUtil selectionUtil       = null)
 {
     jumpList         = jumpList ?? new JumpList(textView, BufferTrackingService);
     statusUtil       = statusUtil ?? CompositionContainer.GetExportedValue <IStatusUtilFactory>().GetStatusUtilForView(textView);
     windowSettings   = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings);
     caretRegisterMap = caretRegisterMap ?? new CaretRegisterMap(Vim.RegisterMap);
     selectionUtil    = selectionUtil ?? new SingleSelectionUtil(textView);
     return(new VimBufferData(
                vimTextBuffer,
                textView,
                windowSettings,
                jumpList,
                statusUtil,
                selectionUtil,
                caretRegisterMap));
 }
Example #21
0
 /// <summary>
 /// This is not technically a Mock but often we want to create it with mocked 
 /// backing values
 /// </summary>
 /// <returns></returns>
 public static VimBufferData CreateVimBufferData(
     IVimTextBuffer vimTextBuffer,
     ITextView textView,
     IJumpList jumpList = null,
     IStatusUtil statusUtil = null,
     IUndoRedoOperations undoRedoOperations = null,
     IVimWindowSettings windowSettings = null,
     IWordUtil wordUtil = null,
     MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     statusUtil = statusUtil ?? factory.Create<IStatusUtil>().Object;
     undoRedoOperations = undoRedoOperations ?? factory.Create<IUndoRedoOperations>().Object;
     jumpList = jumpList ?? factory.Create<IJumpList>().Object;
     wordUtil = wordUtil ?? factory.Create<IWordUtil>().Object;
     windowSettings = windowSettings ?? factory.Create<IVimWindowSettings>().Object;
     return new VimBufferData(
         jumpList,
         textView,
         statusUtil,
         undoRedoOperations,
         vimTextBuffer,
         windowSettings,
         wordUtil);
 }
        public void Create(params string[] lines)
        {
            var tuple = EditorUtil.CreateTextViewAndEditorOperations(lines);
            _textView = tuple.Item1;
            _textBuffer = _textView.TextBuffer;
            var service = EditorUtil.FactoryService;
            _vimBuffer = service.Vim.CreateVimBuffer(_textView);
            _vimBuffer.ErrorMessage +=
                (_, message) =>
                {
                    if (_assertOnErrorMessage)
                    {
                        Assert.Fail("Error Message: " + message);
                    }
                };
            _vimBuffer.WarningMessage +=
                (_, message) =>
                {
                    if (_assertOnWarningMessage)
                    {
                        Assert.Fail("Warning Message: " + message);
                    }
                };
            _vimTextBuffer = _vimBuffer.VimTextBuffer;
            _keyMap = _vimBuffer.Vim.KeyMap;
            _globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
            _jumpList = _vimBuffer.JumpList;
            _vimHost = (MockVimHost)_vimBuffer.Vim.VimHost;
            _vimHost.BeepCount = 0;
            _vimData = service.Vim.VimData;
            _foldManager = EditorUtil.FactoryService.FoldManagerFactory.GetFoldManager(_textView);

            // Many of the operations operate on both the visual and edit / text snapshot
            // simultaneously.  Ensure that our setup code is producing a proper IElisionSnapshot
            // for the Visual portion so we can root out any bad mixing of instances between
            // the two
            Assert.IsTrue(_textView.VisualSnapshot is IElisionSnapshot);
            Assert.IsTrue(_textView.VisualSnapshot != _textView.TextSnapshot);
        }
Example #23
0
        private void Create(params string[] lines)
        {
            _vimHost = (MockVimHost)Vim.VimHost;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimTextBuffer = Vim.CreateVimTextBuffer(_textBuffer);
            _localSettings = _vimTextBuffer.LocalSettings;

            _foldManager = FoldManagerFactory.GetFoldManager(_textView);

            _factory = new MockRepository(MockBehavior.Loose);
            _statusUtil = _factory.Create<IStatusUtil>();
            _smartIdentationService = _factory.Create<ISmartIndentationService>();

            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView,
                statusUtil: _statusUtil.Object);
            _jumpList = vimBufferData.JumpList;
            _windowSettings = vimBufferData.WindowSettings;

            _vimData = Vim.VimData;
            _macroRecorder = Vim.MacroRecorder;
            _registerMap = Vim.RegisterMap;
            _globalSettings = Vim.GlobalSettings;

            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _motionUtil = new MotionUtil(vimBufferData);
            _commandUtil = new CommandUtil(
                vimBufferData,
                _motionUtil,
                operations,
                _smartIdentationService.Object,
                _foldManager,
                new InsertUtil(vimBufferData, operations));
        }
Example #24
0
 public static Mock<IVimBuffer> CreateVimBuffer(
     ITextView textView,
     string name = null,
     IVim vim = null,
     IJumpList jumpList = null,
     IVimLocalSettings localSettings = null,
     IIncrementalSearch incrementalSearch = null,
     IMotionUtil motionUtil = null,
     ITextStructureNavigator wordNavigator = null,
     MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     name = name ?? "test";
     vim = vim ?? CreateVim().Object;
     jumpList = jumpList ?? (factory.Create<IJumpList>().Object);
     motionUtil = motionUtil ?? factory.Create<IMotionUtil>().Object;
     wordNavigator = wordNavigator ?? factory.Create<ITextStructureNavigator>().Object;
     localSettings = localSettings ?? new LocalSettings(vim.GlobalSettings);
     var vimTextBuffer = CreateVimTextBuffer(
         textView.TextBuffer,
         localSettings: localSettings,
         vim: vim,
         factory: factory);
     var mock = factory.Create<IVimBuffer>();
     mock.SetupGet(x => x.TextView).Returns(textView);
     mock.SetupGet(x => x.MotionUtil).Returns(motionUtil);
     mock.SetupGet(x => x.TextBuffer).Returns(() => textView.TextBuffer);
     mock.SetupGet(x => x.TextSnapshot).Returns(() => textView.TextSnapshot);
     mock.SetupGet(x => x.Name).Returns(name);
     mock.SetupGet(x => x.LocalSettings).Returns(localSettings);
     mock.SetupGet(x => x.GlobalSettings).Returns(localSettings.GlobalSettings);
     mock.SetupGet(x => x.MarkMap).Returns(vim.MarkMap);
     mock.SetupGet(x => x.RegisterMap).Returns(vim.RegisterMap);
     mock.SetupGet(x => x.JumpList).Returns(jumpList);
     mock.SetupGet(x => x.Vim).Returns(vim);
     mock.SetupGet(x => x.VimData).Returns(vim.VimData);
     mock.SetupGet(x => x.IncrementalSearch).Returns(incrementalSearch);
     mock.SetupGet(x => x.WordNavigator).Returns(wordNavigator);
     mock.SetupGet(x => x.VimTextBuffer).Returns(vimTextBuffer.Object);
     return mock;
 }
Example #25
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to 
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     ITextView textView,
     IStatusUtil statusUtil = null,
     IJumpList jumpList = null,
     IUndoRedoOperations undoRedoOperations = null,
     IVimWindowSettings windowSettings = null,
     IWordUtil wordUtil = null)
 {
     return CreateVimBufferData(
         Vim.GetOrCreateVimTextBuffer(textView.TextBuffer),
         textView,
         statusUtil,
         jumpList,
         undoRedoOperations,
         windowSettings,
         wordUtil);
 }
Example #26
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to 
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     IVimTextBuffer vimTextBuffer,
     ITextView textView,
     IStatusUtil statusUtil = null,
     IJumpList jumpList = null,
     IUndoRedoOperations undoRedoOperations = null,
     IVimWindowSettings windowSettings = null,
     IWordUtil wordUtil = null)
 {
     jumpList = jumpList ?? new JumpList(textView, _bufferTrackingService);
     statusUtil = statusUtil ?? new StatusUtil();
     undoRedoOperations = undoRedoOperations ?? CreateUndoRedoOperations(statusUtil);
     windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings);
     wordUtil = wordUtil ?? WordUtilFactory.GetWordUtil(vimTextBuffer.TextBuffer);
     return new VimBufferData(
         vimTextBuffer,
         textView,
         windowSettings,
         jumpList,
         statusUtil,
         undoRedoOperations,
         wordUtil);
 }
 internal OperationsImpl(ITextView view, IEditorOperations opts, IVimHost host, IJumpList jumpList)
     : base(view, opts, host, jumpList)
 {
 }
Example #28
0
        protected void Create(params string[] lines)
        {
            _vimHost = (MockVimHost)Vim.VimHost;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimTextBuffer = Vim.CreateVimTextBuffer(_textBuffer);
            _localSettings = _vimTextBuffer.LocalSettings;

            var foldManager = CreateFoldManager(_textView);

            _factory = new MockRepository(MockBehavior.Loose);
            _statusUtil = _factory.Create<IStatusUtil>();
            _bulkOperations = new TestableBulkOperations();

            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView,
                statusUtil: _statusUtil.Object);
            _jumpList = vimBufferData.JumpList;
            _windowSettings = vimBufferData.WindowSettings;

            _vimData = Vim.VimData;
            _macroRecorder = Vim.MacroRecorder;
            _globalSettings = Vim.GlobalSettings;

            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _motionUtil = new MotionUtil(vimBufferData);
            _commandUtil = new CommandUtil(
                vimBufferData,
                _motionUtil,
                operations,
                foldManager,
                new InsertUtil(vimBufferData, operations),
                _bulkOperations);
        }
 public void Create(params string[] lines)
 {
     var tuple = EditorUtil.CreateViewAndOperations(lines);
     _textView = tuple.Item1;
     _textBuffer = _textView.TextBuffer;
     var service = EditorUtil.FactoryService;
     _buffer = service.Vim.CreateBuffer(_textView);
     _buffer.ErrorMessage +=
         (_, message) =>
         {
             if (_assertOnErrorMessage)
             {
                 Assert.Fail("Error Message: " + message);
             }
         };
     _buffer.WarningMessage +=
         (_, message) =>
         {
             if (_assertOnWarningMessage)
             {
                 Assert.Fail("Warning Message: " + message);
             }
         };
     _keyMap = _buffer.Vim.KeyMap;
     _globalSettings = _buffer.Settings.GlobalSettings;
     _jumpList = _buffer.JumpList;
 }
Example #30
0
 private void Create(int limit = 100)
 {
     _tlcService = new Mock<ITrackingLineColumnService>(MockBehavior.Strict);
     _jumpListRaw = new JumpList(_tlcService.Object, limit);
     _jumpList = _jumpListRaw;
 }
Example #31
0
 internal static Mock<IVimBuffer> CreateVimBuffer(
     IWpfTextView view,
     string name = null,
     IVim vim = null,
     IEditorOperations editorOperations = null,
     IJumpList jumpList = null,
     IVimLocalSettings settings = null)
 {
     name = name ?? "test";
     vim = vim ?? CreateVim().Object;
     editorOperations = editorOperations ?? CreateEditorOperations().Object;
     jumpList = jumpList ?? (new Mock<IJumpList>(MockBehavior.Strict)).Object;
     settings = settings ?? new LocalSettings(vim.Settings, view);
     var mock = new Mock<IVimBuffer>(MockBehavior.Strict);
     mock.SetupGet(x => x.TextView).Returns(view);
     mock.SetupGet(x => x.TextBuffer).Returns(() => view.TextBuffer);
     mock.SetupGet(x => x.TextSnapshot).Returns(() => view.TextSnapshot);
     mock.SetupGet(x => x.Name).Returns(name);
     mock.SetupGet(x => x.EditorOperations).Returns(editorOperations);
     mock.SetupGet(x => x.VimHost).Returns(vim.Host);
     mock.SetupGet(x => x.Settings).Returns(settings);
     mock.SetupGet(x => x.MarkMap).Returns(vim.MarkMap);
     mock.SetupGet(x => x.RegisterMap).Returns(vim.RegisterMap);
     mock.SetupGet(x => x.JumpList).Returns(jumpList);
     return mock;
 }
Example #32
0
 /// <summary>
 /// Create a new instance of VimBufferData.  Centralized here to make it easier to 
 /// absorb API changes in the Unit Tests
 /// </summary>
 protected IVimBufferData CreateVimBufferData(
     IVimTextBuffer vimTextBuffer,
     ITextView textView,
     IStatusUtil statusUtil = null,
     IJumpList jumpList = null,
     IVimWindowSettings windowSettings = null,
     IWordUtil wordUtil = null)
 {
     jumpList = jumpList ?? new JumpList(textView, BufferTrackingService);
     statusUtil = statusUtil ?? new StatusUtil();
     windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings);
     wordUtil = wordUtil ?? WordUtil;
     return new VimBufferData(
         vimTextBuffer,
         textView,
         windowSettings,
         jumpList,
         statusUtil,
         wordUtil);
 }
Example #33
0
 public static Mock<IVimBuffer> CreateVimBuffer(
     ITextView view,
     string name = null,
     IVim vim = null,
     IJumpList jumpList = null,
     IVimLocalSettings settings = null,
     MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     name = name ?? "test";
     vim = vim ?? CreateVim().Object;
     jumpList = jumpList ?? (factory.Create<IJumpList>().Object);
     settings = settings ?? new LocalSettings(vim.Settings, view);
     var mock = factory.Create<IVimBuffer>();
     mock.SetupGet(x => x.TextView).Returns(view);
     mock.SetupGet(x => x.TextBuffer).Returns(() => view.TextBuffer);
     mock.SetupGet(x => x.TextSnapshot).Returns(() => view.TextSnapshot);
     mock.SetupGet(x => x.Name).Returns(name);
     mock.SetupGet(x => x.Settings).Returns(settings);
     mock.SetupGet(x => x.MarkMap).Returns(vim.MarkMap);
     mock.SetupGet(x => x.RegisterMap).Returns(vim.RegisterMap);
     mock.SetupGet(x => x.JumpList).Returns(jumpList);
     mock.SetupGet(x => x.Vim).Returns(vim);
     return mock;
 }
 internal OperationsImpl(ITextView view, IEditorOperations opts, IOutliningManager outlining, IVimHost host, IJumpList jumpList, IVimLocalSettings settings, IUndoRedoOperations undoRedoOpts)
     : base(view, opts, outlining, host, jumpList, settings, undoRedoOpts)
 {
 }
Example #35
0
        private void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateView(lines);
            _textBuffer = _textView.TextBuffer;

            _factory = new MockRepository(MockBehavior.Loose);
            _vimHost = _factory.Create<IVimHost>();
            _statusUtil = _factory.Create<IStatusUtil>();
            _operations = _factory.Create<ICommonOperations>();
            _operations.Setup(x => x.EnsureCaretOnScreenAndTextExpanded());
            _operations.Setup(x => x.RaiseSearchResultMessages(It.IsAny<SearchResult>()));
            _operations.Setup(x => x.EditorOptions).Returns(EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(_textView));
            _recorder = _factory.Create<IMacroRecorder>(MockBehavior.Loose);
            _smartIdentationService = _factory.Create<ISmartIndentationService>();

            _vimData = new VimData();
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _markMap = new MarkMap(new TrackingLineColumnService());
            _globalSettings = new GlobalSettings();
            _localSettings = new LocalSettings(_globalSettings, _textView);

            var localSettings = new LocalSettings(new Vim.GlobalSettings());
            _motionUtil = VimUtil.CreateTextViewMotionUtil(
                _textView,
                settings: localSettings,
                vimData: _vimData);
            _commandUtil = VimUtil.CreateCommandUtil(
                _textView,
                _operations.Object,
                _motionUtil,
                statusUtil: _statusUtil.Object,
                localSettings: _localSettings,
                registerMap: _registerMap,
                markMap: _markMap,
                vimData: _vimData,
                smartIndentationService: _smartIdentationService.Object,
                recorder: _recorder.Object);
            _jumpList = _commandUtil._jumpList;
        }