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 }; }
public void Start_DontResetSelection() { Create(VisualKind.Character, ""); var realView = CreateTextView("foo bar baz"); var selection = new Mock <ITextSelection>(MockBehavior.Strict); selection.SetupGet(x => x.IsEmpty).Returns(false).Verifiable(); selection.SetupGet(x => x.IsReversed).Returns(false).Verifiable(); selection.SetupGet(x => x.AnchorPoint).Returns(new VirtualSnapshotPoint(realView.TextSnapshot, 0)); selection.SetupProperty(x => x.Mode); var view = new Mock <ITextView>(MockBehavior.Strict); view.SetupGet(x => x.TextBuffer).Returns(realView.TextBuffer); view.SetupGet(x => x.Caret).Returns(realView.Caret); view.SetupGet(x => x.TextSnapshot).Returns(realView.TextSnapshot); view.SetupGet(x => x.Selection).Returns(selection.Object); var vimTextBuffer = new Mock <IVimTextBuffer>(MockBehavior.Strict); vimTextBuffer.SetupGet(x => x.LocalSettings).Returns(new LocalSettings(_globalSettings)); var vimBufferData = MockObjectFactory.CreateVimBufferData(vimTextBuffer.Object, view.Object); var tracker = new SelectionTracker(vimBufferData, _incrementalSearch.Object, VisualKind.Character); tracker.Start(); selection.Verify(); }
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> >()); }
public void TextViewClosedImmediatelyAfterInitialLayout() { var textBuffer = CreateTextBuffer(""); var vimTextBuffer = _vimBufferFactory.CreateVimTextBuffer(textBuffer, _vim); var textView = MockObjectFactory.CreateTextView(textBuffer, factory: _factory); textView.SetupGet(x => x.TextViewLines).Returns((ITextViewLineCollection)null); textView.SetupGet(x => x.InLayout).Returns(false); textView.SetupGet(x => x.IsClosed).Returns(false); var vimBuffer = _vimBufferFactory.CreateVimBuffer(textView.Object, vimTextBuffer); Assert.Equal(ModeKind.Uninitialized, vimBuffer.ModeKind); textView.SetupGet(x => x.TextViewLines).Returns(() => { var lines = _factory.Create <ITextViewLineCollection>(); lines.SetupGet(x => x.IsValid).Returns(true); return(lines.Object); }); textView.SetupGet(x => x.InLayout).Returns(false); textView.SetupGet(x => x.IsClosed).Returns(false); textView.Raise(x => x.LayoutChanged += null, (TextViewLayoutChangedEventArgs)null); Assert.Equal(ModeKind.Uninitialized, vimBuffer.ModeKind); textView.SetupGet(x => x.IsClosed).Returns(true); textView.SetupGet(x => x.TextViewLines).Throws(new Exception()); DoEvents(); Assert.Equal(ModeKind.Uninitialized, vimBuffer.ModeKind); }
private void Create(params string[] lines) { _textView = EditorUtil.CreateView(lines); _factory = new MockRepository(MockBehavior.Strict); _host = _factory.Create <IVimHost>(); _statusUtil = _factory.Create <IStatusUtil>(); _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object); _vimData = new VimData(); var settings = new GlobalSettings(); var localSettings = new LocalSettings(settings, _textView); var motionUtil = VimUtil.CreateTextViewMotionUtil( _textView, settings: localSettings, vimData: _vimData); var capture = new MotionCapture( _host.Object, _textView, MockObjectFactory.CreateIncrementalSearch(factory: _factory).Object, localSettings); _commandUtil = VimUtil.CreateCommandUtil( _textView, motionUtil: motionUtil, statusUtil: _statusUtil.Object, registerMap: _registerMap, vimData: _vimData); _runnerRaw = new CommandRunner( _textView, _registerMap, capture, _commandUtil, _statusUtil.Object, VisualKind.Character); _runner = _runnerRaw; }
public void GetKeyBindings4() { var com = MockObjectFactory.CreateCommand(0, "name", "::notavalidkey"); var e = Extensions.GetCommandKeyBindings(com.Object).ToList(); Assert.Equal(0, e.Count); }
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)); }
public void MoveCaretToVirtualPoint() { var buffer = CreateTextBuffer("foo", "bar"); var factory = new MockRepository(MockBehavior.Strict); var caret = MockObjectFactory.CreateCaret(factory: factory); caret.Setup(x => x.EnsureVisible()).Verifiable(); caret.SetupGet(x => x.Position).Returns(new CaretPosition()); var selection = MockObjectFactory.CreateSelection(factory: factory); selection.Setup(x => x.Clear()).Verifiable(); var textView = MockObjectFactory.CreateTextView( textBuffer: buffer, selection: selection.Object, caret: caret.Object, factory: factory); var line = factory.Create <ITextViewLine>(); line.SetupGet(x => x.VisibilityState).Returns(VisibilityState.FullyVisible).Verifiable(); textView.Setup(x => x.GetTextViewLineContainingBufferPosition(It.IsAny <SnapshotPoint>())).Returns(line.Object).Verifiable(); var point = new VirtualSnapshotPoint(buffer.GetLine(0), 2); caret.Setup(x => x.MoveTo(point)).Returns(new CaretPosition()).Verifiable(); TextViewUtil.MoveCaretToVirtualPoint(textView.Object, point); factory.Verify(); }
public VimTest() { _factory = new MockRepository(MockBehavior.Strict); _globalSettings = new GlobalSettings(); _markMap = _factory.Create <IMarkMap>(MockBehavior.Strict); _fileSystem = _factory.Create <IFileSystem>(MockBehavior.Strict); _bufferFactory = VimBufferFactory; _keyMap = new KeyMap(_globalSettings); _vimHost = _factory.Create <IVimHost>(MockBehavior.Strict); _searchInfo = _factory.Create <ISearchService>(MockBehavior.Strict); _vimRaw = new Vim( _vimHost.Object, _bufferFactory, FSharpList <Lazy <IVimBufferCreationListener> > .Empty, _globalSettings, _markMap.Object, _keyMap, MockObjectFactory.CreateClipboardDevice().Object, _searchInfo.Object, _fileSystem.Object, new VimData(), _factory.Create <IBulkOperations>().Object); _vim = _vimRaw; _vim.AutoLoadVimRc = false; }
public void SetUp(bool insertMode) { _factory = new MockRepository(MockBehavior.Strict); _factory.DefaultValue = DefaultValue.Mock; _textView = EditorUtil.CreateView(); _vim = _factory.Create <IVim>(MockBehavior.Loose); _editorOptions = _factory.Create <IEditorOptions>(MockBehavior.Loose); _globalSettings = _factory.Create <IVimGlobalSettings>(); _localSettings = _factory.Create <IVimLocalSettings>(); _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object); _textChangeTracker = _factory.Create <ITextChangeTracker>(); _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption <TextChange> .None); _undoRedoOperations = _factory.Create <IUndoRedoOperations>(); _data = MockObjectFactory.CreateVimBuffer( _textView, settings: _localSettings.Object, vim: _vim.Object, factory: _factory); _operations = _factory.Create <ICommonOperations>(); _operations.SetupGet(x => x.EditorOperations).Returns(_factory.Create <IEditorOperations>().Object); _broker = _factory.Create <IDisplayWindowBroker>(); _broker.SetupGet(x => x.IsCompletionActive).Returns(false); _broker.SetupGet(x => x.IsQuickInfoActive).Returns(false); _broker.SetupGet(x => x.IsSignatureHelpActive).Returns(false); _modeRaw = new Vim.Modes.Insert.InsertMode( _data.Object, _operations.Object, _broker.Object, _editorOptions.Object, _undoRedoOperations.Object, _textChangeTracker.Object, _isReplace: !insertMode); _mode = _modeRaw; }
private static KeyBindingUtil Create(params string[] args) { var all = MockObjectFactory.CreateCommandList(args).Select(x => x.Object); var snapshot = new CommandsSnapshot(all); return(new KeyBindingUtil(snapshot)); }
public SelectionChangeTrackerTest() { _factory = new MockRepository(MockBehavior.Loose); _selection = _factory.Create <ITextSelection>(); _textView = MockObjectFactory.CreateTextView( selection: _selection.Object, factory: _factory); _vimHost = _factory.Create <IVimHost>(); _vimHost.Setup(x => x.IsFocused(_textView.Object)).Returns(true); _vimBuffer = MockObjectFactory.CreateVimBuffer( textView: _textView.Object, vim: MockObjectFactory.CreateVim(host: _vimHost.Object).Object, factory: _factory); _vimBuffer.SetupGet(x => x.IsClosed).Returns(false); _mouseDevice = _factory.Create <IMouseDevice>(); _selectionOverride = _factory.Create <IVisualModeSelectionOverride>(); _selectionOverride.Setup(x => x.IsInsertModePreferred(It.IsAny <ITextView>())).Returns(false); var selectionList = new List <IVisualModeSelectionOverride>(); selectionList.Add(_selectionOverride.Object); _context = new TestableSynchronizationContext(); _context.Install(); _tracker = new SelectionChangeTracker(_vimBuffer.Object, _factory.Create <ICommonOperations>(MockBehavior.Loose).Object, selectionList.ToFSharpList(), _mouseDevice.Object); }
public void TextViewInLayoutInsideLayoutEvent() { var textBuffer = CreateTextBuffer(""); var vimTextBuffer = _vimBufferFactory.CreateVimTextBuffer(textBuffer, _vim); var textView = MockObjectFactory.CreateTextView(textBuffer, factory: _factory); textView.SetupGet(x => x.TextViewLines).Returns((ITextViewLineCollection)null); textView.SetupGet(x => x.InLayout).Returns(false); textView.SetupGet(x => x.IsClosed).Returns(false); var vimBuffer = _vimBufferFactory.CreateVimBuffer(textView.Object, vimTextBuffer); Assert.Equal(ModeKind.Uninitialized, vimBuffer.ModeKind); // Still can't initialize here because inside the event we are in another layout // which prevents a mode change textView.SetupGet(x => x.TextViewLines).Throws(new Exception()); textView.SetupGet(x => x.InLayout).Returns(true); textView.Raise(x => x.LayoutChanged += null, (TextViewLayoutChangedEventArgs)null); Assert.Equal(ModeKind.Uninitialized, vimBuffer.ModeKind); textView.SetupGet(x => x.Caret.Position).Returns(new CaretPosition()); textView.SetupGet(x => x.TextViewLines).Returns(_factory.Create <ITextViewLineCollection>().Object); textView.SetupGet(x => x.InLayout).Returns(false); textView.Raise(x => x.LayoutChanged += null, (TextViewLayoutChangedEventArgs)null); Dispatcher.CurrentDispatcher.DoEvents(); Assert.Equal(ModeKind.Normal, vimBuffer.ModeKind); }
private void Create(params string[] lines) { _textBuffer = CreateTextBuffer(lines); _textView = MockObjectFactory.CreateTextView(_textBuffer); _textView.SetupGet(x => x.HasAggregateFocus).Returns(true); // Setup normal mode so that we can provide an ICommandRunner to // recieve commands from _factory = new MockRepository(MockBehavior.Loose) { DefaultValue = DefaultValue.Mock }; _runner = _factory.Create <ICommandRunner>(MockBehavior.Loose); _normalMode = _factory.Create <INormalMode>(MockBehavior.Strict); _normalMode.SetupGet(x => x.CommandRunner).Returns(_runner.Object); // Create the IVimBuffer instance _buffer = _factory.Create <IVimBuffer>(MockBehavior.Loose); _buffer.DefaultValue = DefaultValue.Mock; _buffer.SetupGet(x => x.NormalMode).Returns(_normalMode.Object); _vimData = new VimData(); var vim = MockObjectFactory.CreateVim(vimData: _vimData); _tracker = new ChangeTracker(vim.Object); _tracker.OnVimBufferCreated(_buffer.Object); }
protected virtual void Create(params string[] lines) { _factory = new MockRepository(MockBehavior.Strict); _marginControl = new CommandMarginControl(); _marginControl.StatusLine = String.Empty; _vimBuffer = CreateVimBuffer(lines); _textBuffer = _vimBuffer.TextBuffer; _textView = _vimBuffer.TextView; _keyboardDevice = new MockKeyboardDevice(); var editorFormatMap = _factory.Create <IEditorFormatMap>(MockBehavior.Loose); editorFormatMap.Setup(x => x.GetProperties(It.IsAny <string>())).Returns(new ResourceDictionary()); var fontProperties = MockObjectFactory.CreateFontProperties("Courier New", 10, _factory); var parentVisualElement = _factory.Create <FrameworkElement>(); _controller = new CommandMarginController( _vimBuffer, parentVisualElement.Object, _marginControl, editorFormatMap.Object, fontProperties.Object, new List <Lazy <IOptionsProviderFactory> >()); }
public void GetVisibleSnapshotLines2() { var buffer = CreateTextBuffer("foo", "bar", "dog", "jazz"); var tuple = MockObjectFactory.CreateTextViewWithVisibleLines(buffer, 1, 2); var lines = TextViewUtil.GetVisibleSnapshotLines(tuple.Item1.Object).ToList(); Assert.Equal(new int[] { 1, 2 }, lines.Select(x => x.LineNumber)); }
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[] args) { _dte = MockObjectFactory.CreateDteWithCommands(args); _commandsSnapshot = new CommandsSnapshot(_dte.Object); var sp = MockObjectFactory.CreateVsServiceProvider( Tuple.Create(typeof(SDTE), (object)(_dte.Object)), Tuple.Create(typeof(SVsShell), (object)(new Mock <IVsShell>(MockBehavior.Strict)).Object)); _optionsDialogService = new Mock <IOptionsDialogService>(MockBehavior.Strict); _vimApplicationSettings = new Mock <IVimApplicationSettings>(MockBehavior.Strict); _vimApplicationSettings.SetupGet(x => x.IgnoredConflictingKeyBinding).Returns(false); _vimApplicationSettings.SetupGet(x => x.HaveUpdatedKeyBindings).Returns(false); var list = new List <CommandKeyBinding>(); _vimApplicationSettings.SetupGet(x => x.RemovedBindings).Returns(list.AsReadOnly()); _serviceRaw = new KeyBindingService( sp.Object, _optionsDialogService.Object, new Mock <IProtectedOperations>().Object, _vimApplicationSettings.Object); _service = _serviceRaw; var result = _dte.Object.Commands.Count; }
public void MoveCaretToVirtualPoint() { var buffer = CreateTextBuffer("foo", "bar"); var factory = new MockRepository(MockBehavior.Strict); var caret = MockObjectFactory.CreateCaret(factory: factory); caret.Setup(x => x.EnsureVisible()).Verifiable(); caret.SetupGet(x => x.Position).Returns(new CaretPosition()); var selection = MockObjectFactory.CreateSelection(factory: factory); selection.Setup(x => x.Clear()).Verifiable(); var textView = MockObjectFactory.CreateTextView( textBuffer: buffer, selection: selection.Object, caret: caret.Object, factory: factory); // Make sure we do all the caution checks necessary to ensure the // text view line is valid. textView.SetupGet(x => x.IsClosed).Returns(false).Verifiable(); textView.SetupGet(x => x.InLayout).Returns(false).Verifiable(); var lines = factory.Create<ITextViewLineCollection>(); textView.Setup(x => x.TextViewLines).Returns(lines.Object).Verifiable(); var line = factory.Create<ITextViewLine>(); lines.SetupGet(x => x.IsValid).Returns(true).Verifiable(); lines.Setup(x => x.GetTextViewLineContainingBufferPosition(It.IsAny<SnapshotPoint>())).Returns(line.Object).Verifiable(); line.SetupGet(x => x.IsValid).Returns(true).Verifiable(); line.SetupGet(x => x.VisibilityState).Returns(VisibilityState.FullyVisible).Verifiable(); var point = new VirtualSnapshotPoint(buffer.GetLine(0), 2); caret.Setup(x => x.MoveTo(point)).Returns(new CaretPosition()).Verifiable(); TextViewUtil.MoveCaretToVirtualPoint(textView.Object, point); factory.Verify(); }
private void CreateVim() { var creationListeners = new[] { new Lazy <IVimBufferCreationListener>(() => _simpleListener) }; var markMap = _factory.Create <IMarkMap>(); markMap.Setup(x => x.SetMark(Mark.LastJump, It.IsAny <IVimBufferData>(), 0, 0)).Returns(true); markMap.Setup(x => x.UnloadBuffer(It.IsAny <IVimBufferData>(), "VimTest.cs", 0, 0)).Returns(true); markMap.Setup(x => x.ReloadBuffer(It.IsAny <IVimBufferData>(), "VimTest.cs")).Returns(true); _vimRaw = new Vim( _vimHost.Object, _bufferFactory, CompositionContainer.GetExportedValue <IVimInterpreterFactory>(), creationListeners.ToFSharpList(), _globalSettings, markMap.Object, MockObjectFactory.CreateClipboardDevice().Object, _factory.Create <ISearchService>().Object, _fileSystem.Object, new VimData(_globalSettings), _factory.Create <IBulkOperations>().Object, _variableMap, new EditorToSettingSynchronizer(), new StatusUtilFactory(), CommonOperationsFactory, MouseDevice); _vim = _vimRaw; _vim.AutoLoadDigraphs = false; _vim.AutoLoadVimRc = false; _vim.AutoLoadSessionData = false; }
public void Start_DontResetSelection() { Create(VisualKind.Character, ""); var realView = CreateTextView("foo bar baz"); var selection = new Mock <ITextSelection>(MockBehavior.Strict); var snapshot = new Mock <ITextSnapshot>(MockBehavior.Strict); snapshot.SetupGet(x => x.Length).Returns(1); selection.SetupGet(x => x.IsEmpty).Returns(false).Verifiable(); var nonEmptySpan = new VirtualSnapshotSpan(new SnapshotSpan(snapshot.Object, new Span(0, 1))); selection.SetupGet(x => x.StreamSelectionSpan).Returns(nonEmptySpan).Verifiable(); selection.SetupGet(x => x.IsReversed).Returns(false).Verifiable(); selection.SetupGet(x => x.AnchorPoint).Returns(new VirtualSnapshotPoint(realView.TextSnapshot, 0)); selection.SetupGet(x => x.ActivePoint).Returns(new VirtualSnapshotPoint(realView.TextSnapshot, 1)); selection.SetupGet(x => x.End).Returns(new VirtualSnapshotPoint(realView.TextSnapshot, 1)); selection.SetupProperty(x => x.Mode); var view = new Mock <ITextView>(MockBehavior.Strict); view.SetupGet(x => x.TextBuffer).Returns(realView.TextBuffer); view.SetupGet(x => x.Caret).Returns(realView.Caret); view.SetupGet(x => x.TextSnapshot).Returns(realView.TextSnapshot); view.SetupGet(x => x.Selection).Returns(selection.Object); var vimTextBuffer = new Mock <IVimTextBuffer>(MockBehavior.Strict); vimTextBuffer.SetupGet(x => x.LocalSettings).Returns(new LocalSettings(_globalSettings)); vimTextBuffer.SetupGet(x => x.UseVirtualSpace).Returns(false); vimTextBuffer.SetupSet(x => x.LastVisualSelection = It.IsAny <Microsoft.FSharp.Core.FSharpOption <VisualSelection> >()); var vimBufferData = MockObjectFactory.CreateVimBufferData(vimTextBuffer.Object, view.Object); var tracker = new SelectionTracker(vimBufferData, _commonOperations, _incrementalSearch.Object, VisualKind.Character); tracker.Start(); selection.Verify(); }
protected VimTest() { _factory = new MockRepository(MockBehavior.Strict); _globalSettings = new GlobalSettings(); _fileSystem = _factory.Create <IFileSystem>(MockBehavior.Strict); _bufferFactory = VimBufferFactory; _simpleListener = new SimpleListener(); var creationListeners = new [] { new Lazy <IVimBufferCreationListener>(() => _simpleListener) }; var map = new Dictionary <string, VariableValue>(); _keyMap = new KeyMap(_globalSettings, map); _vimHost = _factory.Create <IVimHost>(MockBehavior.Strict); _vimHost.Setup(x => x.CreateHiddenTextView()).Returns(CreateTextView()); _vimHost.Setup(x => x.AutoSynchronizeSettings).Returns(true); _vimRaw = new Vim( _vimHost.Object, _bufferFactory, CompositionContainer.GetExportedValue <IVimInterpreterFactory>(), creationListeners.ToFSharpList(), _globalSettings, _factory.Create <IMarkMap>().Object, _keyMap, MockObjectFactory.CreateClipboardDevice().Object, _factory.Create <ISearchService>().Object, _fileSystem.Object, new VimData(), _factory.Create <IBulkOperations>().Object, map, new EditorToSettingSynchronizer()); _vim = _vimRaw; _vim.AutoLoadVimRc = false; }
public void Create2( ModeKind kind = ModeKind.VisualCharacter, params string[] lines) { _textView = EditorUtil.CreateView(lines); _textBuffer = _textView.TextBuffer; _selection = _textView.Selection; _factory = new MockRepository(MockBehavior.Strict); _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object); _markMap = new MarkMap(new TrackingLineColumnService()); _tracker = _factory.Create <ISelectionTracker>(); _tracker.Setup(x => x.Start()); _tracker.Setup(x => x.ResetCaret()); _tracker.Setup(x => x.UpdateSelection()); _jumpList = _factory.Create <IJumpList>(MockBehavior.Loose); _undoRedoOperations = _factory.Create <IUndoRedoOperations>(); _foldManager = _factory.Create <IFoldManager>(); _editorOperations = _factory.Create <IEditorOperations>(); _operations = _factory.Create <ICommonOperations>(); _operations.SetupGet(x => x.FoldManager).Returns(_foldManager.Object); _operations.SetupGet(x => x.UndoRedoOperations).Returns(_undoRedoOperations.Object); _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object); _operations.SetupGet(x => x.TextView).Returns(_textView); _host = _factory.Create <IVimHost>(MockBehavior.Loose); _commandUtil = _factory.Create <ICommandUtil>(); _commandUtil .Setup(x => x.RunCommand(It.Is <Command>(y => y.IsLegacyCommand))) .Returns <Command>(c => c.AsLegacyCommand().Item.Function.Invoke(null)); _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory); var globalSettings = new GlobalSettings(); var localSettings = new LocalSettings(globalSettings, _textView); var motionUtil = VimUtil.CreateTextViewMotionUtil( _textView, _markMap, localSettings); _bufferData = MockObjectFactory.CreateVimBuffer( _textView, "test", MockObjectFactory.CreateVim(_map, host: _host.Object, settings: globalSettings).Object, incrementalSearch: _incrementalSearch.Object, jumpList: _jumpList.Object, motionUtil: motionUtil); var capture = new MotionCapture( _host.Object, _textView, _incrementalSearch.Object, localSettings); var runner = new CommandRunner( _textView, _map, capture, _commandUtil.Object, (new Mock <IStatusUtil>()).Object, VisualKind.Character); _modeRaw = new VisualMode(_bufferData.Object, _operations.Object, kind, runner, capture, _tracker.Object); _mode = _modeRaw; _mode.OnEnter(ModeArgument.None); }
public void Init() { _settings = MockObjectFactory.CreateLocalSettings(); _bufferData = new Mock <IVimBuffer>(MockBehavior.Strict); _bufferData.SetupGet(x => x.Settings).Returns(_settings.Object); _modeRaw = new DisabledMode(_bufferData.Object); _mode = _modeRaw; }
protected RegisterMapTest() { _factory = new MockRepository(MockBehavior.Strict); _clipboard = MockObjectFactory.CreateClipboardDevice(_factory); _fileName = null; _rawMap = VimUtil.CreateRegisterMap(_clipboard.Object, () => _fileName); _map = _rawMap; }
public void Can_Generate_Slug_For_Non_Duplicate_Url_4() { const string postTitle = "programatic web.config.config"; var postRepository = MockObjectFactory.CreatePostRepository(); var generatedSlug = UniqueUrlHelper.FindUniqueUrl(postRepository, postTitle, 1); Assert.AreEqual("programatic-web-config-config", generatedSlug); }
/// <summary> /// Creates a mock object. /// </summary> /// <typeparam name="TMock">The type of object to mock.</typeparam> /// <returns></returns> /// <remarks> /// This is where you'd use Reflection.Emit to generate a mock implementation /// </remarks> public TMock CreateMock <TMock>() { IMockRecorder recorder = new MockRecorder <TMock>(); _mockRecorders.Add(recorder); return(MockObjectFactory.CreateMock <TMock>(recorder)); }
public void Can_Generate_Slug_For_Non_Duplicate_Url_2() { const string postTitle = "a test url 20"; var postRepository = MockObjectFactory.CreatePostRepository(); var generatedSlug = UniqueUrlHelper.FindUniqueUrl(postRepository, postTitle, 1); Assert.AreEqual("a-test-url-20-2", generatedSlug); }
private void RaiseLayoutChanged(SnapshotLineRange visibleRange = null) { visibleRange = visibleRange ?? _textBuffer.GetLineRange(0, _textBuffer.CurrentSnapshot.LineCount - 1); _textView .SetupGet(x => x.TextViewLines) .Returns(MockObjectFactory.CreateTextViewLineCollection(visibleRange, _factory).Object); _textView.Raise(x => x.LayoutChanged += null, null, null); }
private void Create(params string[] args) { _dte = MockObjectFactory.CreateDteWithCommands(args); var sp = MockObjectFactory.CreateVsServiceProvider(Tuple.Create(typeof(SDTE), (object)(_dte.Object))); _optionsDialogService = new Mock <IOptionsDialogService>(MockBehavior.Strict); _serviceRaw = new KeyBindingService(sp.Object, _optionsDialogService.Object); _service = _serviceRaw; }