forked from VsVim/VsVim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlockCaretTest.cs
63 lines (58 loc) · 2.11 KB
/
BlockCaretTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Vim;
using NUnit.Framework;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Classification;
using Moq;
using Vim.UI.Wpf.Implementation;
namespace Vim.UI.Wpf.Test
{
[TestFixture]
public class BlockCaretTest
{
private Mock<ITextView> _textview;
private Mock<ITextCaret> _caret;
private Mock<IEditorFormatMap> _formatMap;
private Mock<IAdornmentLayer> _layer;
private BlockCaret _blockCaretRaw;
private IBlockCaret _blockCaret;
private void Create()
{
_caret = new Mock<ITextCaret>(MockBehavior.Strict);
_textview = new Mock<ITextView>(MockBehavior.Strict);
_textview.SetupGet(x => x.Caret).Returns(_caret.Object);
_formatMap = new Mock<IEditorFormatMap>(MockBehavior.Strict);
_layer = new Mock<IAdornmentLayer>(MockBehavior.Strict);
_blockCaretRaw = new BlockCaret(_textview.Object, _formatMap.Object, _layer.Object);
_blockCaret = _blockCaretRaw;
}
[Test]
public void TextView1()
{
Create();
Assert.AreSame(_textview.Object, _blockCaret.TextView);
}
[Test, Description("Don't throw when ContaintingTextViewLine throws")]
public void Show1()
{
Create();
_caret.SetupGet(x => x.ContainingTextViewLine).Throws(new InvalidOperationException());
_blockCaret.CaretDisplay = CaretDisplay.HalfBlock;
_caret.Verify();
Assert.AreEqual(CaretDisplay.HalfBlock, _blockCaret.CaretDisplay);
}
[Test]
public void Hide1()
{
Create();
_caret.Setup(x => x.ContainingTextViewLine).Throws(new InvalidOperationException());
_blockCaret.CaretDisplay = CaretDisplay.HalfBlock;
_caret.Verify();
_blockCaret.CaretDisplay = CaretDisplay.NormalCaret;
_caret.Verify();
}
}
}