public void Create(bool hasTextLines, bool hasTagger, params string[] lines) { _factory = new MockRepository(MockBehavior.Loose); _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _buffer = Vim.CreateVimBuffer(_textView); _vimApplicationSettings = _factory.Create <IVimApplicationSettings>(); _vimApplicationSettings.SetupGet(x => x.EnableExternalEditMonitoring).Returns(true); // Have adatper ignore by default _adapter = _factory.Create <IExternalEditAdapter>(MockBehavior.Strict); _adapter.Setup(x => x.IsExternalEditTag(It.IsAny <ITag>())).Returns(false); _adapter.Setup(x => x.IsExternalEditMarker(It.IsAny <IVsTextLineMarker>())).Returns(false); var adapterList = new List <IExternalEditAdapter> { _adapter.Object }; Result <IVsTextLines> textLines = Result.Error; if (hasTextLines) { _vsTextLines = _factory.Create <IVsTextLines>(MockBehavior.Strict); _vsTextLines.SetupNoEnumMarkers(); textLines = Result.CreateSuccess(_vsTextLines.Object); } var taggerList = new List <ITagger <ITag> >(); if (hasTagger) { _tagger = _factory.Create <ITagger <ITag> >(MockBehavior.Loose); _tagger.Setup(x => x.GetTags(It.IsAny <NormalizedSnapshotSpanCollection>())).Returns(new List <ITagSpan <ITag> >()); taggerList.Add(_tagger.Object); } _monitor = new ExternalEditMonitor( _vimApplicationSettings.Object, _buffer, ProtectedOperations, textLines, taggerList.ToReadOnlyCollectionShallow(), adapterList.ToReadOnlyCollectionShallow()); }
public void Create(bool hasTextLines, bool hasTagger, params string[] lines) { _factory = new MockRepository(MockBehavior.Loose); _textView = EditorUtil.CreateTextView(lines); _textBuffer = _textView.TextBuffer; _buffer = EditorUtil.FactoryService.Vim.CreateVimBuffer(_textView); // Have adatper ignore by default _adapter = _factory.Create <IExternalEditAdapter>(MockBehavior.Strict); _adapter.Setup(x => x.IsExternalEditTag(It.IsAny <ITag>())).Returns(false); _adapter.Setup(x => x.IsExternalEditMarker(It.IsAny <IVsTextLineMarker>())).Returns(false); Result <IVsTextLines> textLines = Result.Error; if (hasTextLines) { _vsTextLines = _factory.Create <IVsTextLines>(MockBehavior.Strict); _vsTextLines.SetupNoEnumMarkers(); textLines = Result.CreateSuccess(_vsTextLines.Object); } Result <ITagger <ITag> > tagger = Result.Error; if (hasTagger) { _tagger = _factory.Create <ITagger <ITag> >(MockBehavior.Loose); _tagger.Setup(x => x.GetTags(It.IsAny <NormalizedSnapshotSpanCollection>())).Returns(new List <ITagSpan <ITag> >()); tagger = Result.CreateSuccess(_tagger.Object); } var list = new List <IExternalEditAdapter> { _adapter.Object }; var adapters = new ReadOnlyCollection <IExternalEditAdapter>(list); _monitor = new ExternalEditMonitor( _buffer, ProtectedOperations, textLines, tagger, adapters); }
public void Setup(bool isShimmed = true, params string[] lines) { _factory = new MockRepository(MockBehavior.Loose); _textBuffer = EditorUtil.CreateBuffer(lines); _textView = MockObjectFactory.CreateTextView(textBuffer: _textBuffer); _buffer = MockObjectFactory.CreateVimBuffer(textView: _textView.Object); _buffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal).Verifiable(); // Have adatper ignore by default _adapter = _factory.Create <IExternalEditAdapter>(MockBehavior.Strict); _adapter.Setup(x => x.IsExternalEditTag(It.IsAny <ITag>())).Returns(false); _adapter.Setup(x => x.IsExternalEditMarker(It.IsAny <IVsTextLineMarker>())).Returns(false); _aggregator = _factory.Create <ITagAggregator <ITag> >(MockBehavior.Strict); SetupTags(); Result <IVsTextLines> result; if (isShimmed) { _vsTextLines = _factory.Create <IVsTextLines>(); _vsTextLines.SetupNoEnumMarkers(); result = Result.CreateSuccess(_vsTextLines.Object); } else { result = Result.Error; } var list = new List <IExternalEditAdapter> { _adapter.Object }; var adapters = new ReadOnlyCollection <IExternalEditAdapter>(list); _monitor = new ExternalEditMonitor( _buffer.Object, result, adapters, _aggregator.Object); }