コード例 #1
0
ファイル: TextViewUtilTest.cs プロジェクト: trigifu/VsVim
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: TextViewUtilTest.cs プロジェクト: bentayloruk/VsVim
        public void MoveCaretToVirtualPoint1()
        {
            var buffer   = EditorUtil.CreateBuffer("foo", "bar");
            var caret    = MockObjectFactory.CreateCaret();
            var textView = MockObjectFactory.CreateTextView(textBuffer: buffer, caret: caret.Object);
            var point    = new VirtualSnapshotPoint(buffer.GetLine(0), 2);

            caret.Setup(x => x.MoveTo(point)).Returns(new CaretPosition()).Verifiable();
            caret.Setup(x => x.EnsureVisible()).Verifiable();
            TextViewUtil.MoveCaretToVirtualPoint(textView.Object, point);
            caret.Verify();
        }
コード例 #4
0
        public void MoveCaretToVirtualPoint()
        {
            var buffer  = CreateTextBuffer("foo", "bar");
            var factory = new MockRepository(MockBehavior.Strict);
            var point   = new VirtualSnapshotPoint(buffer.GetLine(0), 2);

            var caret         = MockObjectFactory.CreateCaret(factory: factory);
            var caretPosition = new CaretPosition(
                point,
                factory.Create <IMappingPoint>().Object,
                PositionAffinity.Predecessor);

            caret.Setup(x => x.EnsureVisible()).Verifiable();
            caret.SetupGet(x => x.Position).Returns(caretPosition).Verifiable();

            // Verify not called: By not creating a setup, it will assert if called.
            //caret.Setup(x => x.MoveTo(point)).Returns(caretPosition).Verifiable();

            var selection = MockObjectFactory.CreateSelection(factory: factory);

            // Verify not called: By not creating a setup, it will assert if called.
            //selection.Setup(x => x.Clear()).Verifiable();

            selection.SetupGet(x => x.IsEmpty).Returns(true).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 span = new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length);

            lines.SetupGet(x => x.FormattedSpan).Returns(span).Verifiable();

            TextViewUtil.MoveCaretToVirtualPoint(textView.Object, point);
            factory.Verify();
        }
コード例 #5
0
ファイル: TextViewUtilTest.cs プロジェクト: zhoutao929/VsVim
        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();

            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 point = new VirtualSnapshotPoint(buffer.GetLine(0), 2);

            caret.Setup(x => x.MoveTo(point)).Returns(new CaretPosition()).Verifiable();

            TextViewUtil.MoveCaretToVirtualPoint(textView.Object, point);
            factory.Verify();
        }