コード例 #1
0
        private void Create(params string[] lines)
        {
            _textView = CreateTextView(lines);
            _factory  = new MockRepository(MockBehavior.Strict);
            _vimHost  = _factory.Create <IVimHost>();
            var registerMap = MockObjectFactory.CreateRegisterMap(factory: _factory);

            _keyMap         = _factory.Create <IKeyMap>();
            _globalSettings = _factory.Create <IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _globalSettings.SetupGet(x => x.WrapScan).Returns(false);
            _searchService = VimUtil.CreateSearchService(_globalSettings.Object);

            // Initialize the Mock<IVim> with all of our Mock'd services
            var vim = MockObjectFactory.CreateVim(
                registerMap: registerMap.Object,
                host: _vimHost.Object,
                keyMap: _keyMap.Object,
                searchService: _searchService,
                settings: _globalSettings.Object,
                vimData: new VimData());

            _localSettings = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object);
            _vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
                _textView.TextBuffer,
                localSettings: _localSettings.Object,
                vim: vim.Object,
                factory: _factory);

            // Initialize the VimBufferData with all of our Mock'd services
            _jumpList           = _factory.Create <IJumpList>();
            _statusUtil         = _factory.Create <IStatusUtil>();
            _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object);
            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer.Object,
                _textView,
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                undoRedoOperations: _undoRedoOperations);

            _outlining        = _factory.Create <IOutliningManager>();
            _editorOperations = _factory.Create <IEditorOperations>();
            _editorOperations.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editorOperations.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            var commonOperations = new CommonOperations(
                vimBufferData,
                _editorOperations.Object,
                FSharpOption.Create(_outlining.Object),
                SmartIndentationService);

            _operationsRaw = new DefaultOperations(
                vimBufferData,
                commonOperations);
            _operations = _operationsRaw;
        }
コード例 #2
0
        private void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateView(lines);
            _factory  = new MockRepository(MockBehavior.Strict);
            _editOpts = _factory.Create <IEditorOperations>();
            _editOpts.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editOpts.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            _host           = _factory.Create <IVimHost>();
            _jumpList       = _factory.Create <IJumpList>();
            _registerMap    = MockObjectFactory.CreateRegisterMap(factory: _factory);
            _globalSettings = _factory.Create <IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _settings           = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object);
            _keyMap             = _factory.Create <IKeyMap>();
            _statusUtil         = _factory.Create <IStatusUtil>();
            _outlining          = _factory.Create <IOutliningManager>();
            _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object);
            _searchService      = VimUtil.CreateSearchService(_globalSettings.Object);

            var data = new OperationsData(
                vimData: new VimData(),
                vimHost: _host.Object,
                textView: _textView,
                editorOperations: _editOpts.Object,
                outliningManager: FSharpOption.Create(_outlining.Object),
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                keyMap: _keyMap.Object,
                undoRedoOperations: _undoRedoOperations,
                editorOptions: null,
                navigator: null,
                foldManager: null,
                registerMap: _registerMap.Object,
                searchService: _searchService);

            _operationsRaw = new DefaultOperations(data);
            _operations    = _operationsRaw;
        }
コード例 #3
0
        private void Create(params string[] lines)
        {
            _view = EditorUtil.CreateView(lines);
            _factory = new MockRepository(MockBehavior.Strict);
            _editOpts = _factory.Create<IEditorOperations>();
            _host = _factory.Create<IVimHost>();
            _jumpList = _factory.Create<IJumpList>();
            _registerMap = MockObjectFactory.CreateRegisterMap(factory: _factory);
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _settings = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object);
            _keyMap = _factory.Create<IKeyMap>();
            _statusUtil = _factory.Create<IStatusUtil>();
            _outlining = _factory.Create<IOutliningManager>();
            _undoRedoOperations = _factory.Create<IUndoRedoOperations>();

            var data = new OperationsData(
                vimHost: _host.Object,
                textView: _view,
                editorOperations: _editOpts.Object,
                outliningManager: _outlining.Object,
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                keyMap: _keyMap.Object,
                undoRedoOperations: _undoRedoOperations.Object,
                editorOptions: null,
                navigator: null,
                foldManager: null,
                registerMap: _registerMap.Object);
            _operationsRaw = new DefaultOperations(data);
            _operations = _operationsRaw;
        }
コード例 #4
0
        private void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateView(lines);
            _factory = new MockRepository(MockBehavior.Strict);
            _editOpts = _factory.Create<IEditorOperations>();
            _editOpts.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editOpts.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            _host = _factory.Create<IVimHost>();
            _jumpList = _factory.Create<IJumpList>();
            _registerMap = MockObjectFactory.CreateRegisterMap(factory: _factory);
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _settings = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object);
            _keyMap = _factory.Create<IKeyMap>();
            _statusUtil = _factory.Create<IStatusUtil>();
            _outlining = _factory.Create<IOutliningManager>();
            _undoRedoOperations = _factory.Create<IUndoRedoOperations>();
            _undoRedoOperations.Setup(x => x.CreateUndoTransaction(It.IsAny<string>())).Returns<string>(name => new UndoTransaction(FSharpOption.Create(EditorUtil.GetUndoHistory(_textView.TextBuffer).CreateTransaction(name))));
            _searchService = new SearchService(EditorUtil.FactoryService.TextSearchService, _globalSettings.Object);

            var data = new OperationsData(
                vimData: new VimData(),
                vimHost: _host.Object,
                textView: _textView,
                editorOperations: _editOpts.Object,
                outliningManager: FSharpOption.Create(_outlining.Object),
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                keyMap: _keyMap.Object,
                undoRedoOperations: _undoRedoOperations.Object,
                editorOptions: null,
                navigator: null,
                foldManager: null,
                registerMap: _registerMap.Object,
                searchService: _searchService,
                smartIndentationService: EditorUtil.FactoryService.SmartIndentationService);
            _operationsRaw = new DefaultOperations(data);
            _operations = _operationsRaw;
        }
コード例 #5
0
        private void Create(
            IEditorOperations editorOpts = null,
            ITextStructureNavigator baseNav = null,
            params string[] lines)
        {
            _host = new Mock<IVimHost>(MockBehavior.Strict);
            if (editorOpts == null)
            {
                var tuple = EditorUtil.CreateViewAndOperations(lines);
                _view = tuple.Item1;
                editorOpts = tuple.Item2;
            }
            else
            {
                _view = EditorUtil.CreateView(lines);
            }

            baseNav = baseNav ?? (new Mock<ITextStructureNavigator>(MockBehavior.Strict)).Object;
            var nav = TssUtil.CreateTextStructureNavigator(WordKind.NormalWord, baseNav);
            _globalSettings = MockObjectFactory.CreateGlobalSettings(ignoreCase: true);
            _settings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object);
            _jumpList = new Mock<IJumpList>(MockBehavior.Strict);
            _searchService = new SearchService(EditorUtil.FactoryService.textSearchService, _globalSettings.Object);
            _search = new Mock<IIncrementalSearch>(MockBehavior.Strict);
            _search.SetupGet(x => x.SearchService).Returns(_searchService);
            _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
            _outlining = new Mock<IOutliningManager>(MockBehavior.Strict);
            _undoRedoOperations = new Mock<IUndoRedoOperations>(MockBehavior.Strict);
            _operationsRaw = new DefaultOperations(_view, editorOpts, _outlining.Object, _host.Object, _statusUtil.Object, _settings.Object, nav, _jumpList.Object, _search.Object, _undoRedoOperations.Object);
            _operations = _operationsRaw;
        }
コード例 #6
0
 private void Create(params string[] lines)
 {
     _view = EditorUtil.CreateView(lines);
     _editOpts = new Mock<IEditorOperations>(MockBehavior.Strict);
     _host = new Mock<IVimHost>(MockBehavior.Strict);
     _jumpList = new Mock<IJumpList>(MockBehavior.Strict);
     _settings = new Mock<IVimLocalSettings>(MockBehavior.Strict);
     _keyMap = new Mock<IKeyMap>(MockBehavior.Strict);
     _operationsRaw = new DefaultOperations(_view, _editOpts.Object, _host.Object, _jumpList.Object, _settings.Object, _keyMap.Object);
     _operations = _operationsRaw;
 }
コード例 #7
0
        private void Create(
            IEditorOperations editorOpts = null,
            ITextStructureNavigator baseNav = null,
            params string[] lines)
        {
            _host = new Mock<IVimHost>(MockBehavior.Strict);
            if (editorOpts == null)
            {
                var tuple = EditorUtil.CreateViewAndOperations(lines);
                _view = tuple.Item1;
                editorOpts = tuple.Item2;
            }
            else
            {
                _view = EditorUtil.CreateView(lines);
            }

            var editorOptions = EditorUtil.FactoryService.editorOptionsFactory.GetOptions(_view);
            baseNav = baseNav ?? (new Mock<ITextStructureNavigator>(MockBehavior.Strict)).Object;
            var nav = TssUtil.CreateTextStructureNavigator(WordKind.NormalWord, baseNav);
            _bufferOptions = new Mock<IEditorOptions>(MockBehavior.Strict);
            _bufferOptions.Setup(x => x.GetOptionValue(DefaultOptions.TabSizeOptionId)).Returns(4);
            _globalSettings = MockObjectFactory.CreateGlobalSettings(ignoreCase: true);
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _settings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object);
            _options = new Mock<IEditorOptions>(MockBehavior.Strict);
            _options.Setup(x => x.GetOptionValue<int>(It.IsAny<string>())).Throws(new ArgumentException());
            _options.Setup(x => x.GetOptionValue<int>(It.IsAny<EditorOptionKey<int>>())).Throws(new ArgumentException());
            _options.Setup(x => x.IsOptionDefined<int>(It.IsAny<EditorOptionKey<int>>(), false)).Returns(true);
            _jumpList = new Mock<IJumpList>(MockBehavior.Strict);
            _searchService = new SearchService(EditorUtil.FactoryService.textSearchService, _globalSettings.Object);
            _search = new Mock<IIncrementalSearch>(MockBehavior.Strict);
            _search.SetupGet(x => x.SearchService).Returns(_searchService);
            _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
            _outlining = new Mock<IOutliningManager>(MockBehavior.Strict);
            _undoRedoOperations = new Mock<IUndoRedoOperations>(MockBehavior.Strict);
            _undoRedoOperations.Setup(x => x.CreateUndoTransaction(It.IsAny<string>())).Returns<string>(name => new Vim.UndoTransaction(FSharpOption.Create(EditorUtil.GetUndoHistory(_view.TextBuffer).CreateTransaction(name))));
            _registerMap = MockObjectFactory.CreateRegisterMap();

            var data = new OperationsData(
                vimHost: _host.Object,
                textView: _view,
                editorOperations: editorOpts,
                outliningManager: _outlining.Object,
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                registerMap: _registerMap.Object,
                keyMap: null,
                undoRedoOperations: _undoRedoOperations.Object,
                editorOptions: _options.Object,
                navigator: null,
                foldManager: null);

            _operationsRaw = new DefaultOperations(data, _search.Object);
            _operations = _operationsRaw;
        }
コード例 #8
0
        private void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateTextView(lines);
            _factory = new MockRepository(MockBehavior.Strict);
            _editOpts = _factory.Create<IEditorOperations>();
            _editOpts.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editOpts.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            _host = _factory.Create<IVimHost>();
            _jumpList = _factory.Create<IJumpList>();
            _registerMap = MockObjectFactory.CreateRegisterMap(factory: _factory);
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _localSettings = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object);
            _keyMap = _factory.Create<IKeyMap>();
            _statusUtil = _factory.Create<IStatusUtil>();
            _outlining = _factory.Create<IOutliningManager>();
            _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object);
            _searchService = VimUtil.CreateSearchService(_globalSettings.Object);

            var vimData = new VimData();
            var data = new OperationsData(
                vimData: vimData,
                vimHost: _host.Object,
                textView: _textView,
                editorOperations: _editOpts.Object,
                outliningManager: FSharpOption.Create(_outlining.Object),
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                localSettings: _localSettings.Object,
                keyMap: _keyMap.Object,
                undoRedoOperations: _undoRedoOperations,
                editorOptions: null,
                foldManager: null,
                registerMap: _registerMap.Object,
                searchService: _searchService,
                wordUtil: VimUtil.GetWordUtil(_textView));
            _operationsRaw = new DefaultOperations(
                new CommonOperations(data),
                _textView,
                _editOpts.Object,
                _jumpList.Object,
                _localSettings.Object,
                _undoRedoOperations,
                _keyMap.Object,
                vimData,
                _host.Object,
                _statusUtil.Object);
            _operations = _operationsRaw;
        }
コード例 #9
0
        private void Create(params string[] lines)
        {
            _textView = CreateTextView(lines);
            _factory = new MockRepository(MockBehavior.Strict);
            _vimHost = _factory.Create<IVimHost>();
            var registerMap = MockObjectFactory.CreateRegisterMap(factory: _factory);
            _keyMap = _factory.Create<IKeyMap>();
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _searchService = VimUtil.CreateSearchService(_globalSettings.Object);

            // Initialize the Mock<IVim> with all of our Mock'd services
            var vim = MockObjectFactory.CreateVim(
                registerMap: registerMap.Object,
                host: _vimHost.Object,
                keyMap: _keyMap.Object,
                searchService: _searchService,
                settings: _globalSettings.Object,
                vimData: new VimData());

            _localSettings = MockObjectFactory.CreateLocalSettings(global: _globalSettings.Object);
            _vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
                _textView.TextBuffer,
                localSettings: _localSettings.Object,
                vim: vim.Object,
                factory: _factory);

            // Initialize the VimBufferData with all of our Mock'd services
            _jumpList = _factory.Create<IJumpList>();
            _statusUtil = _factory.Create<IStatusUtil>();
            _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object);
            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer.Object,
                _textView,
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                undoRedoOperations: _undoRedoOperations);

            _outlining = _factory.Create<IOutliningManager>();
            _editorOperations = _factory.Create<IEditorOperations>();
            _editorOperations.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editorOperations.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            var commonOperations = new CommonOperations(
                vimBufferData,
                _editorOperations.Object,
                FSharpOption.Create(_outlining.Object));

            _operationsRaw = new DefaultOperations(
                vimBufferData,
                commonOperations);
            _operations = _operationsRaw;
        }