|
1 | 1 | using NUnit.Framework; |
2 | | -using Moq; |
3 | 2 | using Rubberduck.AutoComplete.Service; |
4 | | -using Rubberduck.Settings; |
5 | 3 | using Rubberduck.VBEditor; |
6 | | -using Rubberduck.VBEditor.SourceCodeHandling; |
7 | | -using Rubberduck.VBEditor.Events; |
8 | | -using Rubberduck.VBEditor.SafeComWrappers.Abstract; |
9 | 4 |
|
10 | 5 | namespace RubberduckTests.AutoComplete |
11 | 6 | { |
12 | | - public class SelfClosingPairTestInfo |
13 | | - { |
14 | | - public SelfClosingPairTestInfo(CodeString original, char input, CodeString rePrettified) |
15 | | - : this(new Mock<SelfClosingPairCompletionService>(), original, original, input, rePrettified) { } |
16 | | - |
17 | | - public SelfClosingPairTestInfo(CodeString original, char input) |
18 | | - : this(new Mock<SelfClosingPairCompletionService>(), original, original, input, original) { } |
19 | | - |
20 | | - public SelfClosingPairTestInfo(CodeString original, CodeString prettified, char input) |
21 | | - : this(new Mock<SelfClosingPairCompletionService>(), original, prettified, input, prettified) { } |
22 | | - |
23 | | - public SelfClosingPairTestInfo(Mock<SelfClosingPairCompletionService> service, CodeString original, CodeString prettified, char input, CodeString rePrettified, bool isControlKeyDown = false, bool isDeleteKey = false) |
24 | | - { |
25 | | - Original = original; |
26 | | - Prettified = prettified; |
27 | | - Input = input; |
28 | | - RePrettified = rePrettified; |
29 | | - Settings = AutoCompleteSettings.AllEnabled; |
30 | | - |
31 | | - Service = service; |
32 | | - Module = new Mock<ICodeModule>(); |
33 | | - Handler = new Mock<ICodePaneHandler>(); |
34 | | - Handler.Setup(e => e.GetCurrentLogicalLine(Module.Object)).Returns(original); |
35 | | - Handler.SetupSequence(e => e.Prettify(Module.Object, It.IsAny<CodeString>())) |
36 | | - .Returns(prettified) |
37 | | - .Returns(rePrettified); |
38 | | - |
39 | | - Args = new AutoCompleteEventArgs(Module.Object, input, isControlKeyDown, isDeleteKey); |
40 | | - } |
41 | | - |
42 | | - public Mock<ICodeModule> Module { get; set; } |
43 | | - public Mock<SelfClosingPairCompletionService> Service { get; set; } |
44 | | - public Mock<ICodePaneHandler> Handler { get; set; } |
45 | | - public CodeString Original { get; set; } |
46 | | - public CodeString Prettified { get; set; } |
47 | | - public char Input { get; set; } |
48 | | - public CodeString RePrettified { get; set; } |
49 | | - public AutoCompleteEventArgs Args { get; set; } |
50 | | - public AutoCompleteSettings Settings { get; set; } |
51 | | - |
52 | | - public TestCodeString Result { get; set; } |
53 | | - } |
54 | | - |
55 | 7 | [TestFixture] |
56 | 8 | public class SelfClosingPairHandlerTests |
57 | 9 | { |
@@ -114,6 +66,21 @@ public void GivenOpeningParenthesisOnCallStatement_ReturnsFalseAndLetsKeypressTh |
114 | 66 | Assert.IsFalse(Run(info)); |
115 | 67 | Assert.IsFalse(info.Args.Handled); |
116 | 68 | } |
| 69 | + |
| 70 | + [Test] |
| 71 | + public void GivenOpeningCharInsideMultilineArgumentList_ReturnsTrueAndSwallowsKeypress() |
| 72 | + { |
| 73 | + var input = '"'; |
| 74 | + var original = @"Err.Raise 5, _ |
| 75 | + |".ToCodeString(); |
| 76 | + var rePrettified = @"Err.Raise 5, _ |
| 77 | + ""|""".ToCodeString(); |
| 78 | + var info = new SelfClosingPairTestInfo(original, input, rePrettified); |
| 79 | + |
| 80 | + Assert.IsTrue(Run(info)); |
| 81 | + Assert.IsTrue(info.Args.Handled); |
| 82 | + } |
| 83 | + |
117 | 84 | [Test] |
118 | 85 | public void GivenBackspaceOnMatchedPair_DeletesMatchingTokens() |
119 | 86 | { |
|
0 commit comments