Code Coverage Statistics for Source File

C:\Users\Marcus\Documents\MyCode\2007\SharpSelectWord\SharpSelectWordTest\Src\ExtendBlockSelectionTest.cs

Sequence Point Coverage
N/A
0 of 0
Branch Coverage
N/A
0 of 0
Lines
259
Highlight: Uncovered Code Covered Code
L V Source
1
using ICSharpCode.TextEditor.Document;
2
using MarcusHolmgren.SharpDevelop.SelectWord;
3
using NUnit.Framework;
4
5
namespace MarcusHolmgren.SharpDevelop.SelectWordTest
6
{
7
    [TestFixture]
8
    public class ExtendBlockSelectionTest
9
    {
10
        [Test, ExpectedException(typeof(System.ArgumentNullException))]
11
        public void NullDocumentConstructorParameter()
12
        {
13
            new ExtendBlockSelection(null, null);
14
        }
15
16
        [Test, ExpectedException(typeof(System.ArgumentNullException))]
17
        public void NullSelectionConstructorParameter()
18
        {
19
            IDocument document = TestHelper.MakeDocument(string.Empty);
20
            new ExtendBlockSelection(document, null);
21
        }
22
23
        [Test]
24
        public void ExtendSelection()
25
        {
26
            const string TextMessage = "using(workflowRuntime)\n\n\n\tstring name = \"|Darth Vader\"";
27
            int offset;
28
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
29
            
30
            ISelection selection = new SingleWordSelection(document, offset);
31
            SelectionManager selectionManager = new SelectionManager(document);
32
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
33
            Assert.AreEqual("Darth", selectionManager.SelectedText);
34
35
            selection = new ExtendBlockSelection(document, selection);
36
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
37
            Assert.AreEqual("\"Darth Vader\"", selectionManager.SelectedText);
38
            TestHelper.CallAllProperties(selection);
39
        }
40
41
        //[Test]
42
        public void ExtendSelection2()
43
        {
44
            const string TextMessage = "using(workflowRuntime)\n\n\n\tstring name = \"Darth Vader|\"";
45
            int offset;
46
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
47
            ISelection selection = new SingleWordSelection(document, offset);
48
            SelectionManager selectionManager = new SelectionManager(document);
49
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
50
            Assert.AreEqual("Vader", selectionManager.SelectedText);
51
52
            selection = new ExtendBlockSelection(document, selection);
53
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
54
            Assert.AreEqual("\"Darth Vader\"", selectionManager.SelectedText);
55
            TestHelper.CallAllProperties(selection);
56
57
            selection = new ExtendBlockSelection(document, selection);
58
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
59
            Assert.AreEqual("\tstring name = \"Darth Vader\"", selectionManager.SelectedText);
60
            TestHelper.CallAllProperties(selection);
61
62
            selection = new ExtendBlockSelection(document, selection);
63
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
64
            Assert.AreEqual("\tstring name = \"Darth Vader\"", selectionManager.SelectedText);
65
            TestHelper.CallAllProperties(selection);
66
        }
67
68
        //[Test]
69
        public void ExtendSelection3()
70
        {
71
            const string TextMessage = "Console.WriteLine|(\"Is the bug fixed?\");";
72
            int offset;
73
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
74
            ISelection selection = new SingleWordSelection(document, offset);
75
            SelectionManager selectionManager = new SelectionManager(document);
76
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
77
            Assert.AreEqual("WriteLine", selectionManager.SelectedText);
78
79
            selection = new ExtendBlockSelection(document, selection);
80
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
81
            Assert.AreEqual("Console.WriteLine", selectionManager.SelectedText);
82
            TestHelper.CallAllProperties(selection);
83
        }
84
85
        [Test]
86
        public void ExtendSelectionStartOfDocument()
87
        {
88
            const string TextMessage = "|Console.WriteLine(\"Is the bug fixed?\");";
89
            int offset;
90
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
91
            ISelection selection = new SingleWordSelection(document, offset);
92
            SelectionManager selectionManager = new SelectionManager(document);
93
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
94
            Assert.AreEqual("Console", selectionManager.SelectedText);
95
96
            selection = new ExtendBlockSelection(document, selection);
97
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
98
            Assert.AreEqual("Console.WriteLine(\"", selectionManager.SelectedText);
99
            TestHelper.CallAllProperties(selection);
100
        }
101
102
        [Test]
103
        public void ExtendSelectionEndOfDocument()
104
        {
105
            const string TextMessage = "Console.WriteLine(\"Is the bug fixed?\");'|";
106
            int offset;
107
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
108
            ISelection selection = new SingleWordSelection(document, offset);
109
            SelectionManager selectionManager = new SelectionManager(document);
110
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
111
            Assert.IsEmpty(selectionManager.SelectedText);
112
113
            selection = new ExtendBlockSelection(document, selection);
114
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
115
            Assert.AreEqual("\");'", selectionManager.SelectedText);
116
            TestHelper.CallAllProperties(selection);
117
        }
118
119
120
        [Test]
121
        public void ExtendSelectionNegativeOffSet()
122
        {
123
            const string TextMessage = "Console.WriteLine(\"Is the bug fixed?\");";
124
            IDocument document = TestHelper.MakeDocument(TextMessage);
125
            int offset = -1;
126
            ISelection selection = new SingleWordSelection(document, offset);
127
            SelectionManager selectionManager = new SelectionManager(document);
128
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
129
            Assert.AreEqual("Console", selectionManager.SelectedText);
130
131
            selection = new ExtendBlockSelection(document, selection);
132
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
133
            Assert.AreEqual("Console.WriteLine(\"", selectionManager.SelectedText);
134
            TestHelper.CallAllProperties(selection);
135
        }
136
137
        [Test]
138
        public void ExtendSelectionOffsetOutsideText()
139
        {
140
            const string TextMessage = "Console.WriteLine(\"Is the bug fixed?\");";
141
            IDocument document = TestHelper.MakeDocument(TextMessage);
142
            int offset = 249;
143
            ISelection selection = new SingleWordSelection(document, offset);
144
            SelectionManager selectionManager = new SelectionManager(document);
145
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
146
            Assert.AreEqual("", selectionManager.SelectedText);
147
148
            selection = new ExtendBlockSelection(document, selection);
149
            TestHelper.CallAllProperties(selection);
150
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
151
            Assert.AreEqual("\");", selectionManager.SelectedText);
152
        }
153
154
        [Test]
155
        public void ExtendBlock()
156
        {
157
            const string TextMessage = "\n\n\tstring doobii = \"Aha a |unit test\";\t\n\n\n";
158
            int offset;
159
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
160
161
            ISelection selection = new SingleWordSelection(document, offset);
162
            SelectionManager selectionManager = new SelectionManager(document);
163
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
164
            Assert.AreEqual("unit", selectionManager.SelectedText);
165
166
            selection = new ExtendBlockSelection(document, selection);
167
            TestHelper.CallAllProperties(selection);
168
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
169
            Assert.AreEqual("\"Aha a unit test\"", selectionManager.SelectedText);
170
171
            selection = new ExtendBlockSelection(document, selection);
172
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
173
            Assert.AreEqual("\tstring doobii = \"Aha a unit test\";\t\n", selectionManager.SelectedText);
174
        }
175
176
        [Test]
177
        public void Whawhoooiii()
178
        {
179
            const string TextMessage =
180
                "\n{\nConsole.WriteLine();\n\tConsole.WriteLine(\"Get back| to work!\");\n\tConsole.WriteLine();\n}\n";
181
            int offset;
182
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
183
184
            ISelection selection = new SingleWordSelection(document, offset);
185
            SelectionManager selectionManager = new SelectionManager(document);
186
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
187
            Assert.AreEqual("back", selectionManager.SelectedText);
188
189
            selection = new ExtendBlockSelection(document, selection);
190
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
191
            Assert.AreEqual("\"Get back to work!\"", selectionManager.SelectedText);
192
193
            selection = new ExtendBlockSelection(document, selection);
194
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
195
            Assert.AreEqual("(\"Get back to work!\")", selectionManager.SelectedText);
196
197
            selection = new ExtendBlockSelection(document, selection);
198
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
199
            Assert.AreEqual("\tConsole.WriteLine(\"Get back to work!\");\n", selectionManager.SelectedText);
200
201
            selection = new ExtendBlockSelection(document, selection);
202
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
203
            Assert.AreEqual("Console.WriteLine();\n\tConsole.WriteLine(\"Get back to work!\");\n\tConsole.WriteLine();\n", selectionManager.SelectedText);
204
        }
205
206
        [Test]
207
        public void Whawhoooiii2342()
208
        {
209
            const string TextMessage =
210
                "\n{\nConsole.WriteLine();\n\tConsole.WriteLine(\"Get back to w|ork!\");\n\tConsole.WriteLine();\n}\n";
211
            int offset;
212
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
213
214
            ISelection selection = new SingleWordSelection(document, offset);
215
            SelectionManager selectionManager = new SelectionManager(document);
216
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
217
            Assert.AreEqual("work!", selectionManager.SelectedText);
218
219
            selection = new ExtendBlockSelection(document, selection);
220
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
221
            Assert.AreEqual("\"Get back to work!\"", selectionManager.SelectedText);
222
223
            selection = new ExtendBlockSelection(document, selection);
224
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
225
            Assert.AreEqual("(\"Get back to work!\")", selectionManager.SelectedText);
226
227
            selection = new ExtendBlockSelection(document, selection);
228
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
229
            Assert.AreEqual("\tConsole.WriteLine(\"Get back to work!\");\n", selectionManager.SelectedText);
230
231
            selection = new ExtendBlockSelection(document, selection);
232
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
233
            Assert.AreEqual("Console.WriteLine();\n\tConsole.WriteLine(\"Get back to work!\");\n\tConsole.WriteLine();\n", selectionManager.SelectedText);
234
        }
235
236
        [Test]
237
        public void ExtendBlockToCurrentLine()
238
        {
239
            const string TextMessage = "\n\n\tstring doobii = \"Aha a |unit test\";\t\n\n\n";
240
            int offset;
241
            IDocument document = TestHelper.MakeDocument(TextMessage, out offset);
242
243
            ISelection selection = new SingleWordSelection(document, offset);
244
            SelectionManager selectionManager = new SelectionManager(document);
245
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
246
            Assert.AreEqual("unit", selectionManager.SelectedText);
247
248
            selection = new ExtendBlockSelection(document, selection);
249
            TestHelper.CallAllProperties(selection);
250
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
251
            Assert.AreEqual("\"Aha a unit test\"", selectionManager.SelectedText);
252
253
            selection = new ExtendBlockSelection(document, selection);
254
            selectionManager.SetSelection(selection.StartPosition, selection.EndPosition);
255
            Assert.AreEqual("\tstring doobii = \"Aha a unit test\";\t\n", selectionManager.SelectedText);
256
257
        }
258
    }
259
}