public void Create(params string[] lines) { _textView = CreateTextView(lines); _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0)); _textBuffer = _textView.TextBuffer; _factory = new MockRepository(MockBehavior.Strict); _editOpts = _factory.Create <IEditorOperations>(); _vimHost = _factory.Create <IVimHost>(); _vimHost.Setup(x => x.IsDirty(It.IsAny <ITextBuffer>())).Returns(false); _operations = _factory.Create <ICommonOperations>(); _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object); _statusUtil = _factory.Create <IStatusUtil>(); _fileSystem = _factory.Create <IFileSystem>(MockBehavior.Strict); _foldManager = _factory.Create <IFoldManager>(MockBehavior.Strict); _vimData = VimData; _vim = MockObjectFactory.CreateVim(RegisterMap, host: _vimHost.Object, vimData: _vimData, factory: _factory); var localSettings = new LocalSettings(Vim.GlobalSettings); var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer( _textBuffer, vim: _vim.Object, localSettings: localSettings, factory: _factory); var vimBufferData = CreateVimBufferData( vimTextBuffer.Object, _textView, statusUtil: _statusUtil.Object); var vimBuffer = CreateVimBuffer(vimBufferData); _interpreter = new Interpreter.VimInterpreter( vimBuffer, _operations.Object, _foldManager.Object, _fileSystem.Object, _factory.Create <IBufferTrackingService>().Object); }
public void Create(params string[] lines) { _textView = CreateTextView(lines); _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0)); _textBuffer = _textView.TextBuffer; _factory = new MockRepository(MockBehavior.Strict); _editOpts = _factory.Create<IEditorOperations>(); _vimHost = _factory.Create<IVimHost>(); _vimHost.Setup(x => x.IsDirty(It.IsAny<ITextBuffer>())).Returns(false); _operations = _factory.Create<ICommonOperations>(); _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object); _statusUtil = _factory.Create<IStatusUtil>(); _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict); _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict); _vimData = VimData; _vim = MockObjectFactory.CreateVim(RegisterMap, host: _vimHost.Object, vimData: _vimData, factory: _factory); var localSettings = new LocalSettings(Vim.GlobalSettings); var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer( _textBuffer, vim: _vim.Object, localSettings: localSettings, factory: _factory); var vimBufferData = CreateVimBufferData( vimTextBuffer.Object, _textView, statusUtil: _statusUtil.Object); var vimBuffer = CreateVimBuffer(vimBufferData); _interpreter = new Interpreter.VimInterpreter( vimBuffer, _operations.Object, _foldManager.Object, _fileSystem.Object, _factory.Create<IBufferTrackingService>().Object); }
private void Create(params string[] lines) { _textView = CreateTextView(lines); _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0)); _textBuffer = _textView.TextBuffer; _factory = new MockRepository(MockBehavior.Strict); _editOpts = _factory.Create <IEditorOperations>(); _vimHost = _factory.Create <IVimHost>(); _vimHost.Setup(x => x.IsDirty(It.IsAny <ITextBuffer>())).Returns(false); _vimHost.Setup(x => x.GetName(It.IsAny <ITextBuffer>())).Returns("CommandProcessorLegacyTest.cs"); _vimHost.Setup(x => x.DoActionWhenTextViewReady(It.IsAny <FSharpFunc <Unit, Unit> >(), It.IsAny <ITextView>())) .Callback((FSharpFunc <Unit, Unit> action, ITextView textView) => action.Invoke(null)); _operations = _factory.Create <ICommonOperations>(); _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object); _operations .Setup(x => x.CreateRegisterValue(It.IsAny <SnapshotPoint>(), It.IsAny <StringData>(), It.IsAny <OperationKind>())) .Returns <SnapshotPoint, StringData, OperationKind>((point, stringData, operationKind) => new RegisterValue(stringData, operationKind)); _statusUtil = _factory.Create <IStatusUtil>(); _fileSystem = _factory.Create <IFileSystem>(MockBehavior.Strict); _foldManager = _factory.Create <IFoldManager>(MockBehavior.Strict); _vimData = VimData; _vim = MockObjectFactory.CreateVim(RegisterMap, host: _vimHost.Object, vimData: _vimData, factory: _factory); var localSettings = new LocalSettings(Vim.GlobalSettings); var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer( _textBuffer, vim: _vim.Object, localSettings: localSettings, factory: _factory); vimTextBuffer.Setup(x => x.InOneTimeCommand).Returns(FSharpOption <ModeKind> .None); var vimBufferData = CreateVimBufferData( vimTextBuffer.Object, _textView, statusUtil: _statusUtil.Object); var vimBuffer = CreateVimBuffer(vimBufferData); _interpreter = new Interpreter.VimInterpreter( vimBuffer, _operations.Object, _foldManager.Object, _fileSystem.Object, _factory.Create <IBufferTrackingService>().Object); }
protected virtual void Create(params string[] lines) { _statusUtil = new TestableStatusUtil(); _vimData = Vim.VimData; _vimBufferData = CreateVimBufferData( CreateTextView(lines), statusUtil: _statusUtil); _vimBuffer = CreateVimBuffer(_vimBufferData); _vimTextBuffer = _vimBufferData.VimTextBuffer; _windowSettings = _vimBufferData.WindowSettings; _localSettings = _vimBufferData.LocalSettings; _globalSettings = _localSettings.GlobalSettings; _textBuffer = _vimBufferData.TextBuffer; _textView = _vimBufferData.TextView; _interpreter = new global::Vim.Interpreter.VimInterpreter( _vimBuffer, CommonOperationsFactory.GetCommonOperations(_vimBufferData), FoldManagerFactory.GetFoldManager(_vimBufferData.TextView), new FileSystem(), BufferTrackingService); _keyMap = Vim.KeyMap; }
public void SpecialMarksAreSet() { var s_emptyList = FSharpList <Mark> .Empty; OpenFakeVimBufferTestWindow(""); var interpreter = new VimInterpreter( _vimBuffer, CommonOperationsFactory.GetCommonOperations(_vimBufferData), FoldManagerFactory.GetFoldManager(_vimBufferData.TextView), new FileSystem(), BufferTrackingService); _vimBuffer.ProcessNotation("<ESC>i1<CR>2<CR>3<CR>4<CR>5<CR>6<CR>7<CR>8<CR>9<CR>0<ESC>"); interpreter.RunDisplayMarks(s_emptyList); var expectedMarks = new[] { @"mark line col file/text", @" ' 1 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 1 0 VimBufferTest.cs", //@" ] 10 1 VimBufferTest.cs", @" ^ 10 1 VimBufferTest.cs", @" . 10 0 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); // set an upper and lower mark _vimBuffer.ProcessNotation("kmzkmZ"); _vimBuffer.ProcessNotation("1G"); interpreter.RunDisplayMarks(s_emptyList); expectedMarks = new[] { @"mark line col file/text", @" ' 8 0 VimBufferTest.cs", @" z 9 0 VimBufferTest.cs", @" Z 8 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 1 0 VimBufferTest.cs", //@" ] 10 1 VimBufferTest.cs", @" ^ 10 1 VimBufferTest.cs", @" . 10 0 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); _vimBuffer.ProcessNotation("yy"); interpreter.RunDisplayMarks(s_emptyList); expectedMarks = new[] { @"mark line col file/text", @" ' 8 0 VimBufferTest.cs", @" z 9 0 VimBufferTest.cs", @" Z 8 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 1 0 VimBufferTest.cs", //@" ] 10 1 VimBufferTest.cs", @" ^ 10 1 VimBufferTest.cs", @" . 10 0 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); // set an upper and lower mark _vimBuffer.ProcessNotation("jmajmA2k"); _vimBuffer.ProcessNotation("5jp"); interpreter.RunDisplayMarks(s_emptyList); expectedMarks = new[] { @"mark line col file/text", @" ' 9 0 VimBufferTest.cs", @" a 2 0 VimBufferTest.cs", @" z 10 0 VimBufferTest.cs", @" A 3 0 VimBufferTest.cs", @" Z 9 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 7 0 VimBufferTest.cs", //@" ] 7 1 VimBufferTest.cs", @" ^ 11 1 VimBufferTest.cs", @" . 7 1 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); _vimBuffer.ProcessNotation("kV<ESC>"); interpreter.RunDisplayMarks(s_emptyList); expectedMarks = new[] { @"mark line col file/text", @" ' 9 0 VimBufferTest.cs", @" a 2 0 VimBufferTest.cs", @" z 10 0 VimBufferTest.cs", @" A 3 0 VimBufferTest.cs", @" Z 9 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 7 0 VimBufferTest.cs", //@" ] 7 1 VimBufferTest.cs", @" ^ 11 1 VimBufferTest.cs", @" . 7 1 VimBufferTest.cs", @" < 6 0 VimBufferTest.cs", @" > 6 1 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); }
public void SpecialMarksAreSet() { var s_emptyList = FSharpList<Mark>.Empty; OpenFakeVimBufferTestWindow(""); var interpreter = new VimInterpreter( _vimBuffer, CommonOperationsFactory.GetCommonOperations(_vimBufferData), FoldManagerFactory.GetFoldManager(_vimBufferData.TextView), new FileSystem(), BufferTrackingService); _vimBuffer.ProcessNotation("<ESC>i1<CR>2<CR>3<CR>4<CR>5<CR>6<CR>7<CR>8<CR>9<CR>0<ESC>"); interpreter.RunDisplayMarks(s_emptyList); var expectedMarks = new[] { @"mark line col file/text", @" ' 1 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 1 0 VimBufferTest.cs", //@" ] 10 1 VimBufferTest.cs", @" ^ 10 1 VimBufferTest.cs", @" . 10 0 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); // set an upper and lower mark _vimBuffer.ProcessNotation("kmzkmZ"); _vimBuffer.ProcessNotation("1G"); interpreter.RunDisplayMarks(s_emptyList); expectedMarks = new[] { @"mark line col file/text", @" ' 8 0 VimBufferTest.cs", @" z 9 0 VimBufferTest.cs", @" Z 8 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 1 0 VimBufferTest.cs", //@" ] 10 1 VimBufferTest.cs", @" ^ 10 1 VimBufferTest.cs", @" . 10 0 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); _vimBuffer.ProcessNotation("yy"); interpreter.RunDisplayMarks(s_emptyList); expectedMarks = new[] { @"mark line col file/text", @" ' 8 0 VimBufferTest.cs", @" z 9 0 VimBufferTest.cs", @" Z 8 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 1 0 VimBufferTest.cs", //@" ] 10 1 VimBufferTest.cs", @" ^ 10 1 VimBufferTest.cs", @" . 10 0 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); // set an upper and lower mark _vimBuffer.ProcessNotation("jmajmA2k"); _vimBuffer.ProcessNotation("5jp"); interpreter.RunDisplayMarks(s_emptyList); expectedMarks = new[] { @"mark line col file/text", @" ' 9 0 VimBufferTest.cs", @" a 2 0 VimBufferTest.cs", @" z 10 0 VimBufferTest.cs", @" A 3 0 VimBufferTest.cs", @" Z 9 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 7 0 VimBufferTest.cs", //@" ] 7 1 VimBufferTest.cs", @" ^ 11 1 VimBufferTest.cs", @" . 7 1 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); _vimBuffer.ProcessNotation("kV<ESC>"); interpreter.RunDisplayMarks(s_emptyList); expectedMarks = new[] { @"mark line col file/text", @" ' 9 0 VimBufferTest.cs", @" a 2 0 VimBufferTest.cs", @" z 10 0 VimBufferTest.cs", @" A 3 0 VimBufferTest.cs", @" Z 9 0 VimBufferTest.cs", @" "" 1 0 VimBufferTest.cs", //@" [ 7 0 VimBufferTest.cs", //@" ] 7 1 VimBufferTest.cs", @" ^ 11 1 VimBufferTest.cs", @" . 7 1 VimBufferTest.cs", @" < 6 0 VimBufferTest.cs", @" > 6 1 VimBufferTest.cs", }; Assert.Equal(string.Join(Environment.NewLine, expectedMarks), _statusUtil.LastStatus); }