~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// TestFormattingVisitor.cs
 
3
//  
 
4
// Author:
 
5
//       Mike KrĆ¼ger <mkrueger@novell.com>
 
6
// 
 
7
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
 
8
// 
 
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
10
// of this software and associated documentation files (the "Software"), to deal
 
11
// in the Software without restriction, including without limitation the rights
 
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
13
// copies of the Software, and to permit persons to whom the Software is
 
14
// furnished to do so, subject to the following conditions:
 
15
// 
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
// 
 
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
25
// THE SOFTWARE.
 
26
 
 
27
using System;
 
28
using System.IO;
 
29
using NUnit.Framework;
 
30
using ICSharpCode.NRefactory.CSharp;
 
31
 
 
32
namespace ICSharpCode.NRefactory.CSharp.FormattingTests
 
33
{
 
34
        [TestFixture()]
 
35
        public class TestSpacingVisitor : TestBase
 
36
        {
 
37
                [Test]
 
38
                public void TestFieldSpacesBeforeComma1()
 
39
                {
 
40
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
41
                        policy.ClassBraceStyle = BraceStyle.EndOfLine;
 
42
                        policy.SpaceBeforeFieldDeclarationComma = false;
 
43
                        policy.SpaceAfterFieldDeclarationComma = false;
 
44
                        
 
45
                        Test(policy, @"class Test {
 
46
        int a           ,                   b,          c;
 
47
}",
 
48
@"class Test {
 
49
        int a,b,c;
 
50
}");
 
51
                }
 
52
 
 
53
                [Test]
 
54
                public void TestFieldSpacesBeforeComma2 ()
 
55
                {
 
56
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
57
                        policy.ClassBraceStyle = BraceStyle.EndOfLine;
 
58
                        policy.SpaceBeforeFieldDeclarationComma = true;
 
59
                        policy.SpaceAfterFieldDeclarationComma = true;
 
60
                        
 
61
                        Test (policy, @"class Test {
 
62
        int a           ,                   b,          c;
 
63
}",
 
64
@"class Test {
 
65
        int a , b , c;
 
66
}");
 
67
                }
 
68
 
 
69
                [Test]
 
70
                public void TestFixedFieldSpacesBeforeComma ()
 
71
                {
 
72
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
73
                        policy.ClassBraceStyle = BraceStyle.EndOfLine;
 
74
                        policy.SpaceAfterFieldDeclarationComma = true;
 
75
                        policy.SpaceBeforeFieldDeclarationComma = true;
 
76
                        
 
77
                        Test (policy, @"class Test {
 
78
        fixed int a[10]           ,                   b[10],          c[10];
 
79
}",
 
80
        @"class Test {
 
81
        fixed int a[10] , b[10] , c[10];
 
82
}");
 
83
                }
 
84
 
 
85
                [Test]
 
86
                public void TestConstFieldSpacesBeforeComma ()
 
87
                {
 
88
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
89
                        policy.ClassBraceStyle = BraceStyle.EndOfLine;
 
90
                        policy.SpaceAfterFieldDeclarationComma = false;
 
91
                        policy.SpaceBeforeFieldDeclarationComma = false;
 
92
                        
 
93
                        Test (policy, @"class Test {
 
94
        const int a = 1           ,                   b = 2,          c = 3;
 
95
}",
 
96
@"class Test {
 
97
        const int a = 1,b = 2,c = 3;
 
98
}");
 
99
                }
 
100
 
 
101
                [Test]
 
102
                public void TestBeforeMethodDeclarationParentheses ()
 
103
                {
 
104
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
105
                        policy.SpaceBeforeMethodDeclarationParentheses = true;
 
106
                        
 
107
                        Test (policy, @"public abstract class Test
 
108
{
 
109
        public abstract Test TestMethod();
 
110
}",
 
111
@"public abstract class Test
 
112
{
 
113
        public abstract Test TestMethod ();
 
114
}");
 
115
                }
 
116
 
 
117
                [Test]
 
118
                public void TestBeforeConstructorDeclarationParenthesesDestructorCase ()
 
119
                {
 
120
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
121
                        policy.SpaceBeforeConstructorDeclarationParentheses = true;
 
122
                        
 
123
                        Test (policy, @"class Test
 
124
{
 
125
        ~Test()
 
126
        {
 
127
        }
 
128
}",
 
129
@"class Test
 
130
{
 
131
        ~Test ()
 
132
        {
 
133
        }
 
134
}");
 
135
                }
 
136
 
 
137
                static void TestBinaryOperator (CSharpFormattingOptions policy, string op)
 
138
                {
 
139
                        var result = GetResult (policy, "class Test { void TestMe () { result = left" + op + "right; } }");
 
140
                        
 
141
                        int i1 = result.Text.IndexOf ("left");
 
142
                        int i2 = result.Text.IndexOf ("right") + "right".Length;
 
143
                        if (i1 < 0 || i2 < 0)
 
144
                                Assert.Fail ("text invalid:" + result.Text);
 
145
                        Assert.AreEqual ("left " + op + " right", result.GetText (i1, i2 - i1));
 
146
                }
 
147
 
 
148
                [Test]
 
149
                public void TestSpacesAroundMultiplicativeOperator ()
 
150
                {
 
151
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
152
                        policy.SpaceAroundMultiplicativeOperator = true;
 
153
                        
 
154
                        TestBinaryOperator (policy, "*");
 
155
                        TestBinaryOperator (policy, "/");
 
156
                }
 
157
 
 
158
                [Test]
 
159
                public void TestSpacesAroundShiftOperator ()
 
160
                {
 
161
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
162
                        policy.SpaceAroundShiftOperator = true;
 
163
                        TestBinaryOperator (policy, "<<");
 
164
                        TestBinaryOperator (policy, ">>");
 
165
                }
 
166
 
 
167
                [Test]
 
168
                public void TestSpacesAroundAdditiveOperator ()
 
169
                {
 
170
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
171
                        policy.SpaceAroundAdditiveOperator = true;
 
172
                        
 
173
                        TestBinaryOperator (policy, "+");
 
174
                        TestBinaryOperator (policy, "-");
 
175
                }
 
176
 
 
177
                [Test]
 
178
                public void TestSpacesAroundBitwiseOperator ()
 
179
                {
 
180
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
181
                        policy.SpaceAroundBitwiseOperator = true;
 
182
                        
 
183
                        TestBinaryOperator (policy, "&");
 
184
                        TestBinaryOperator (policy, "|");
 
185
                        TestBinaryOperator (policy, "^");
 
186
                }
 
187
 
 
188
                [Test]
 
189
                public void TestSpacesAroundRelationalOperator ()
 
190
                {
 
191
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
192
                        policy.SpaceAroundRelationalOperator = true;
 
193
                        
 
194
                        TestBinaryOperator (policy, "<");
 
195
                        TestBinaryOperator (policy, "<=");
 
196
                        TestBinaryOperator (policy, ">");
 
197
                        TestBinaryOperator (policy, ">=");
 
198
                }
 
199
 
 
200
                [Test]
 
201
                public void TestSpacesAroundEqualityOperator ()
 
202
                {
 
203
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
204
                        policy.SpaceAroundEqualityOperator = true;
 
205
                        
 
206
                        TestBinaryOperator (policy, "==");
 
207
                        TestBinaryOperator (policy, "!=");
 
208
                }
 
209
 
 
210
                [Test]
 
211
                public void TestSpacesAroundLogicalOperator ()
 
212
                {
 
213
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
214
                        policy.SpaceAroundLogicalOperator = true;
 
215
                        
 
216
                        TestBinaryOperator (policy, "&&");
 
217
                        TestBinaryOperator (policy, "||");
 
218
                }
 
219
 
 
220
                [Test]
 
221
                public void TestConditionalOperator ()
 
222
                {
 
223
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
224
                        policy.SpaceBeforeConditionalOperatorCondition = true;
 
225
                        policy.SpaceAfterConditionalOperatorCondition = true;
 
226
                        policy.SpaceBeforeConditionalOperatorSeparator = true;
 
227
                        policy.SpaceAfterConditionalOperatorSeparator = true;
 
228
                        
 
229
                        var result = GetResult (policy, @"class Test {
 
230
        void TestMe ()
 
231
        {
 
232
                result = condition?trueexpr:falseexpr;
 
233
        }
 
234
}");
 
235
                        int i1 = result.Text.IndexOf ("condition");
 
236
                        int i2 = result.Text.IndexOf ("falseexpr") + "falseexpr".Length;
 
237
                        Assert.AreEqual (@"condition ? trueexpr : falseexpr", result.GetText (i1, i2 - i1));
 
238
                        
 
239
                        
 
240
                        policy.SpaceBeforeConditionalOperatorCondition = false;
 
241
                        policy.SpaceAfterConditionalOperatorCondition = false;
 
242
                        policy.SpaceBeforeConditionalOperatorSeparator = false;
 
243
                        policy.SpaceAfterConditionalOperatorSeparator = false;
 
244
                        
 
245
                        result = GetResult (policy, @"class Test {
 
246
        void TestMe ()
 
247
        {
 
248
                result = true ? trueexpr : falseexpr;
 
249
        }
 
250
}");
 
251
                        i1 = result.Text.IndexOf ("true");
 
252
                        i2 = result.Text.IndexOf ("falseexpr") + "falseexpr".Length;
 
253
                        Assert.AreEqual (@"true?trueexpr:falseexpr", result.GetText (i1, i2 - i1));
 
254
                }
 
255
 
 
256
                [Test]
 
257
                public void TestBeforeMethodCallParenthesesSpace ()
 
258
                {
 
259
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
260
                        policy.SpaceBeforeMethodCallParentheses = true;
 
261
                        
 
262
                        var result = GetResult (policy, @"class Test {
 
263
        void TestMe ()
 
264
        {
 
265
                MethodCall();
 
266
        }
 
267
}");
 
268
                        
 
269
                        int i1 = result.Text.IndexOf ("MethodCall");
 
270
                        int i2 = result.Text.IndexOf (";") + ";".Length;
 
271
                        Assert.AreEqual (@"MethodCall ();", result.GetText (i1, i2 - i1));
 
272
                        
 
273
                        
 
274
                        result = GetResult (policy, @"class Test {
 
275
        void TestMe ()
 
276
        {
 
277
                MethodCall                                                      ();
 
278
        }
 
279
}");
 
280
                        policy.SpaceBeforeMethodCallParentheses = false;
 
281
                        
 
282
                        result = GetResult (policy, result.Text);
 
283
                        i1 = result.Text.IndexOf ("MethodCall");
 
284
                        i2 = result.Text.IndexOf (";") + ";".Length;
 
285
                        Assert.AreEqual (@"MethodCall();", result.GetText (i1, i2 - i1));
 
286
                }
 
287
 
 
288
                [Test]
 
289
                public void TestWithinMethodCallParenthesesSpace ()
 
290
                {
 
291
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
292
                        policy.SpaceWithinMethodCallParentheses = true;
 
293
                        
 
294
                        var result = GetResult (policy, @"class Test {
 
295
        void TestMe ()
 
296
        {
 
297
                MethodCall(true);
 
298
        }
 
299
}");
 
300
                        int i1 = result.Text.LastIndexOf ("(");
 
301
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
302
                        Assert.AreEqual (@"( true )", result.GetText (i1, i2 - i1));
 
303
                        
 
304
                        
 
305
                        policy.SpaceWithinMethodCallParentheses = false;
 
306
                        result = GetResult (policy, @"class Test {
 
307
        void TestMe ()
 
308
        {
 
309
                MethodCall( true );
 
310
        }
 
311
}");
 
312
                        
 
313
                        i1 = result.Text.LastIndexOf ("(");
 
314
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
315
                        Assert.AreEqual (@"(true)", result.GetText (i1, i2 - i1));
 
316
                }
 
317
 
 
318
                [Test]
 
319
                public void TestBeforeIfParenthesesSpace ()
 
320
                {
 
321
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
322
                        policy.SpaceBeforeIfParentheses = true;
 
323
                        
 
324
                        var result = GetResult (policy, @"class Test {
 
325
        void TestMe ()
 
326
        {
 
327
                if(true);
 
328
        }
 
329
}");
 
330
                        int i1 = result.Text.IndexOf ("if");
 
331
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
332
                        Assert.AreEqual (@"if (true)", result.GetText (i1, i2 - i1));
 
333
                }
 
334
 
 
335
                [Test]
 
336
                public void TestWithinIfParenthesesSpace ()
 
337
                {
 
338
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
339
                        policy.SpacesWithinIfParentheses = true;
 
340
                        
 
341
                        var result = GetResult (policy, @"class Test {
 
342
        void TestMe ()
 
343
        {
 
344
                if (true);
 
345
        }
 
346
}");
 
347
                        int i1 = result.Text.LastIndexOf ("(");
 
348
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
349
                        Assert.AreEqual (@"( true )", result.GetText (i1, i2 - i1));
 
350
                }
 
351
 
 
352
                [Test]
 
353
                public void TestBeforeWhileParenthesesSpace ()
 
354
                {
 
355
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
356
                        policy.SpaceBeforeWhileParentheses = true;
 
357
                        
 
358
                        var result = GetResult (policy, @"class Test {
 
359
        void TestMe ()
 
360
        {
 
361
                while(true);
 
362
        }
 
363
}");
 
364
                        int i1 = result.Text.IndexOf ("while");
 
365
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
366
                        Assert.AreEqual (@"while (true)", result.GetText (i1, i2 - i1));
 
367
                }
 
368
 
 
369
                [Test]
 
370
                public void TestWithinWhileParenthesesSpace ()
 
371
                {
 
372
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
373
                        policy.SpacesWithinWhileParentheses = true;
 
374
                        
 
375
                        var result = GetResult (policy, @"class Test {
 
376
        void TestMe ()
 
377
        {
 
378
                while (true);
 
379
        }
 
380
}");
 
381
                        
 
382
                        int i1 = result.Text.LastIndexOf ("(");
 
383
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
384
                        Assert.AreEqual (@"( true )", result.GetText (i1, i2 - i1));
 
385
                }
 
386
 
 
387
                [Test]
 
388
                public void TestBeforeForParenthesesSpace ()
 
389
                {
 
390
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
391
                        policy.SpaceBeforeForParentheses = true;
 
392
                        
 
393
                        var result = GetResult (policy, @"class Test {
 
394
        void TestMe ()
 
395
        {
 
396
                for(;;);
 
397
        }
 
398
}");
 
399
                        int i1 = result.Text.IndexOf ("for");
 
400
                        int i2 = result.Text.LastIndexOf ("(") + "(".Length;
 
401
                        Assert.AreEqual (@"for (", result.GetText (i1, i2 - i1));
 
402
                }
 
403
 
 
404
                [Test]
 
405
                public void TestWithinForParenthesesSpace ()
 
406
                {
 
407
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
408
                        policy.SpacesWithinForParentheses = true;
 
409
                
 
410
                        var result = GetResult (policy, @"class Test {
 
411
        void TestMe ()
 
412
        {
 
413
                for(;;);
 
414
        }
 
415
}");
 
416
                        int i1 = result.Text.LastIndexOf ("(");
 
417
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
418
                        Assert.AreEqual (@"( ;; )", result.GetText (i1, i2 - i1));
 
419
                }
 
420
 
 
421
                [Test]
 
422
                public void TestBeforeForeachParenthesesSpace ()
 
423
                {
 
424
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
425
                        policy.SpaceBeforeForeachParentheses = true;
 
426
                        
 
427
                        var result = GetResult (policy, @"class Test {
 
428
        void TestMe ()
 
429
        {
 
430
                foreach(var o in list);
 
431
        }
 
432
}");
 
433
                        int i1 = result.Text.IndexOf ("foreach");
 
434
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
435
                        Assert.AreEqual (@"foreach (var o in list)", result.GetText (i1, i2 - i1));
 
436
                }
 
437
 
 
438
                [Test]
 
439
                public void TestWithinForeachParenthesesSpace ()
 
440
                {
 
441
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
442
                        policy.SpacesWithinForeachParentheses = true;
 
443
                        
 
444
                        var result = GetResult (policy, @"class Test {
 
445
        void TestMe ()
 
446
        {
 
447
                foreach(var o in list);
 
448
        }
 
449
}");
 
450
                        int i1 = result.Text.LastIndexOf ("(");
 
451
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
452
                        Assert.AreEqual (@"( var o in list )", result.GetText (i1, i2 - i1));
 
453
                }
 
454
 
 
455
                [Test]
 
456
                public void TestBeforeCatchParenthesesSpace ()
 
457
                {
 
458
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
459
                        policy.SpaceBeforeCatchParentheses = true;
 
460
                        
 
461
                        var result = GetResult (policy, @"class Test {
 
462
        void TestMe ()
 
463
        {
 
464
  try {} catch(Exception) {}
 
465
        }
 
466
}");
 
467
                        int i1 = result.Text.IndexOf ("catch");
 
468
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
469
                        Assert.AreEqual (@"catch (Exception)", result.GetText (i1, i2 - i1));
 
470
                }
 
471
 
 
472
                [Test]
 
473
                public void TestWithinCatchParenthesesSpace ()
 
474
                {
 
475
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
476
                        policy.SpacesWithinCatchParentheses = true;
 
477
                        
 
478
                        var result = GetResult (policy, @"class Test {
 
479
        void TestMe ()
 
480
        {
 
481
                try {} catch(Exception) {}
 
482
        }
 
483
}");
 
484
                        int i1 = result.Text.LastIndexOf ("(");
 
485
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
486
                        Assert.AreEqual (@"( Exception )", result.GetText (i1, i2 - i1));
 
487
                }
 
488
 
 
489
                [Test]
 
490
                public void TestBeforeLockParenthesesSpace ()
 
491
                {
 
492
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
493
                        policy.SpaceBeforeLockParentheses = true;
 
494
                        
 
495
                        var result = GetResult (policy, @"class Test {
 
496
        void TestMe ()
 
497
        {
 
498
                lock(this) {}
 
499
        }
 
500
}");
 
501
                        int i1 = result.Text.IndexOf ("lock");
 
502
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
503
                        Assert.AreEqual (@"lock (this)", result.GetText (i1, i2 - i1));
 
504
                }
 
505
 
 
506
                [Test]
 
507
                public void TestWithinLockParenthesesSpace ()
 
508
                {
 
509
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
510
                        policy.SpacesWithinLockParentheses = true;
 
511
                        
 
512
                        var result = GetResult (policy, @"class Test {
 
513
        void TestMe ()
 
514
        {
 
515
                lock(this) {}
 
516
        }
 
517
}");
 
518
                        int i1 = result.Text.LastIndexOf ("(");
 
519
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
520
                        Assert.AreEqual (@"( this )", result.GetText (i1, i2 - i1));
 
521
                }
 
522
 
 
523
                [Test]
 
524
                public void TestSpacesAfterForSemicolon ()
 
525
                {
 
526
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
527
                        policy.SpaceAfterForSemicolon = true;
 
528
                        
 
529
                        var result = GetResult (policy, @"class Test {
 
530
        void TestMe ()
 
531
        {
 
532
                for (int i;true;i++) ;
 
533
        }
 
534
}");
 
535
                        int i1 = result.Text.LastIndexOf ("for");
 
536
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
537
                        
 
538
                        Assert.AreEqual (@"for (int i; true; i++)", result.GetText (i1, i2 - i1));
 
539
                }
 
540
 
 
541
                [Test]
 
542
                public void TestSpacesBeforeForSemicolon ()
 
543
                {
 
544
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
545
                        policy.SpaceBeforeForSemicolon = true;
 
546
                        policy.SpaceAfterForSemicolon = false;
 
547
                        
 
548
                        var result = GetResult (policy, @"class Test {
 
549
        void TestMe ()
 
550
        {
 
551
                for (int i;true;i++) ;
 
552
        }
 
553
}");
 
554
                        int i1 = result.Text.LastIndexOf ("for");
 
555
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
556
                        
 
557
                        Assert.AreEqual (@"for (int i ;true ;i++)", result.GetText (i1, i2 - i1));
 
558
                }
 
559
 
 
560
                [Test]
 
561
                public void TestSpacesAfterTypecast ()
 
562
                {
 
563
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
564
                        policy.SpaceAfterTypecast = true;
 
565
                        
 
566
                        var result = GetResult (policy, @"class Test {
 
567
        Test TestMe ()
 
568
        {
 
569
return (Test)null;
 
570
        }
 
571
}");
 
572
                        int i1 = result.Text.LastIndexOf ("return");
 
573
                        int i2 = result.Text.LastIndexOf ("null") + "null".Length;
 
574
                        
 
575
                        Assert.AreEqual (@"return (Test) null", result.GetText (i1, i2 - i1));
 
576
                }
 
577
 
 
578
                [Test]
 
579
                public void TestBeforeUsingParenthesesSpace ()
 
580
                {
 
581
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
582
                        policy.SpaceBeforeUsingParentheses = true;
 
583
                        
 
584
                        var result = GetResult (policy, @"class Test {
 
585
        void TestMe ()
 
586
        {
 
587
                using(a) {}
 
588
        }
 
589
}");
 
590
                        int i1 = result.Text.IndexOf ("using");
 
591
                        int i2 = result.Text.LastIndexOf ("(") + "(".Length;
 
592
                        Assert.AreEqual (@"using (", result.GetText (i1, i2 - i1));
 
593
                }
 
594
 
 
595
                [Test]
 
596
                public void TestWithinUsingParenthesesSpace ()
 
597
                {
 
598
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
599
                        policy.SpacesWithinUsingParentheses = true;
 
600
                        
 
601
                        var result = GetResult (policy, @"class Test {
 
602
        void TestMe ()
 
603
        {
 
604
                using(a) {}
 
605
        }
 
606
}");
 
607
                        int i1 = result.Text.LastIndexOf ("(");
 
608
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
609
                        Assert.AreEqual (@"( a )", result.GetText (i1, i2 - i1));
 
610
                }
 
611
 
 
612
                static void TestAssignmentOperator (CSharpFormattingOptions policy, string op)
 
613
                {
 
614
                        var result = GetResult (policy, "class Test { void TestMe () { left" + op + "right; } }");
 
615
                        
 
616
                        int i1 = result.Text.IndexOf ("left");
 
617
                        int i2 = result.Text.IndexOf ("right") + "right".Length;
 
618
                        if (i1 < 0 || i2 < 0)
 
619
                                Assert.Fail ("text invalid:" + result.Text);
 
620
                        Assert.AreEqual ("left " + op + " right", result.GetText (i1, i2 - i1));
 
621
                }
 
622
 
 
623
                [Test]
 
624
                public void TestAroundAssignmentSpace ()
 
625
                {
 
626
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
627
                        policy.SpaceAroundAssignment = true;
 
628
                        
 
629
                        TestAssignmentOperator (policy, "=");
 
630
                        TestAssignmentOperator (policy, "*=");
 
631
                        TestAssignmentOperator (policy, "/=");
 
632
                        TestAssignmentOperator (policy, "+=");
 
633
                        TestAssignmentOperator (policy, "%=");
 
634
                        TestAssignmentOperator (policy, "-=");
 
635
                        TestAssignmentOperator (policy, "<<=");
 
636
                        TestAssignmentOperator (policy, ">>=");
 
637
                        TestAssignmentOperator (policy, "&=");
 
638
                        TestAssignmentOperator (policy, "|=");
 
639
                        TestAssignmentOperator (policy, "^=");
 
640
                }
 
641
 
 
642
                [Test]
 
643
                public void TestAroundAssignmentSpaceInDeclarations ()
 
644
                {
 
645
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
646
                        policy.SpaceAroundAssignment = true;
 
647
                        var result = GetResult (policy, @"class Test {
 
648
        void TestMe ()
 
649
        {
 
650
                int left=right;
 
651
        }
 
652
}");
 
653
                        
 
654
                        int i1 = result.Text.LastIndexOf ("left");
 
655
                        int i2 = result.Text.LastIndexOf ("right") + "right".Length;
 
656
                        Assert.AreEqual (@"left = right", result.GetText (i1, i2 - i1));
 
657
                }
 
658
 
 
659
                [Test]
 
660
                public void TestBeforeSwitchParenthesesSpace ()
 
661
                {
 
662
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
663
                        policy.SpaceBeforeSwitchParentheses = true;
 
664
                        
 
665
                        var result = GetResult (policy, @"class Test {
 
666
        void TestMe ()
 
667
        {
 
668
                switch (test) { default: break; }
 
669
        }
 
670
}");
 
671
                        int i1 = result.Text.IndexOf ("switch");
 
672
                        int i2 = result.Text.LastIndexOf ("(") + "(".Length;
 
673
                        Assert.AreEqual (@"switch (", result.GetText (i1, i2 - i1));
 
674
                }
 
675
 
 
676
                [Test]
 
677
                public void TestWithinSwitchParenthesesSpace ()
 
678
                {
 
679
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
680
                        policy.SpacesWithinSwitchParentheses = true;
 
681
                        
 
682
                        var result = GetResult (policy, @"class Test {
 
683
        void TestMe ()
 
684
        {
 
685
                switch (test) { default: break; }
 
686
        }
 
687
}");
 
688
                        int i1 = result.Text.LastIndexOf ("(");
 
689
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
690
                        Assert.AreEqual (@"( test )", result.GetText (i1, i2 - i1));
 
691
                }
 
692
 
 
693
                [Test]
 
694
                public void TestWithinParenthesesSpace ()
 
695
                {
 
696
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
697
                        policy.SpacesWithinParentheses = true;
 
698
                        
 
699
                        var result = GetResult (policy, @"class Test {
 
700
        void TestMe ()
 
701
        {
 
702
                c = (test);
 
703
        }
 
704
}");
 
705
                        int i1 = result.Text.LastIndexOf ("(");
 
706
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
707
                        Assert.AreEqual (@"( test )", result.GetText (i1, i2 - i1));
 
708
                }
 
709
 
 
710
                [Test]
 
711
                public void TestWithinMethodDeclarationParenthesesSpace ()
 
712
                {
 
713
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
714
                        policy.SpaceWithinMethodDeclarationParentheses = true;
 
715
                        
 
716
                        var result = GetResult (policy, @"class Test {
 
717
        void TestMe (int a)
 
718
        {
 
719
        }
 
720
}");
 
721
                        int i1 = result.Text.LastIndexOf ("(");
 
722
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
723
                        Assert.AreEqual (@"( int a )", result.GetText (i1, i2 - i1));
 
724
                }
 
725
 
 
726
                [Test]
 
727
                public void TestWithinCastParenthesesSpace ()
 
728
                {
 
729
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
730
                        policy.SpacesWithinCastParentheses = true;
 
731
                        
 
732
                        var result = GetResult (policy, @"class Test {
 
733
        void TestMe ()
 
734
        {
 
735
                a = (int)b;
 
736
        }
 
737
}");
 
738
                        int i1 = result.Text.LastIndexOf ("(");
 
739
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
740
                        Assert.AreEqual (@"( int )", result.GetText (i1, i2 - i1));
 
741
                }
 
742
 
 
743
                [Test]
 
744
                public void TestWithinSizeOfParenthesesSpace ()
 
745
                {
 
746
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
747
                        policy.SpacesWithinSizeOfParentheses = true;
 
748
                        
 
749
                        var result = GetResult (policy, @"class Test {
 
750
        void TestMe ()
 
751
        {
 
752
                a = sizeof(int);
 
753
        }
 
754
}");
 
755
                        int i1 = result.Text.LastIndexOf ("(");
 
756
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
757
                        Assert.AreEqual (@"( int )", result.GetText (i1, i2 - i1));
 
758
                }
 
759
 
 
760
                [Test]
 
761
                public void TestBeforeSizeOfParentheses ()
 
762
                {
 
763
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
764
                        policy.SpaceBeforeSizeOfParentheses = true;
 
765
                        
 
766
                        var result = GetResult (policy, @"class Test {
 
767
        void TestMe ()
 
768
        {
 
769
                a = sizeof(int);
 
770
        }
 
771
}");
 
772
                        int i1 = result.Text.LastIndexOf ("sizeof");
 
773
                        int i2 = result.Text.LastIndexOf ("(") + "(".Length;
 
774
                        Assert.AreEqual (@"sizeof (", result.GetText (i1, i2 - i1));
 
775
                }
 
776
 
 
777
                [Test]
 
778
                public void TestWithinTypeOfParenthesesSpace ()
 
779
                {
 
780
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
781
                        policy.SpacesWithinTypeOfParentheses = true;
 
782
                        
 
783
                        var result = GetResult (policy, @"class Test {
 
784
        void TestMe ()
 
785
        {
 
786
                a = typeof(int);
 
787
        }
 
788
}");
 
789
                        int i1 = result.Text.LastIndexOf ("(");
 
790
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
791
                        Assert.AreEqual (@"( int )", result.GetText (i1, i2 - i1));
 
792
                }
 
793
 
 
794
                [Test]
 
795
                public void TestBeforeTypeOfParentheses ()
 
796
                {
 
797
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
798
                        policy.SpaceBeforeTypeOfParentheses = true;
 
799
                        
 
800
                        var result = GetResult (policy, @"class Test {
 
801
        void TestMe ()
 
802
        {
 
803
                a = typeof(int);
 
804
        }
 
805
}");
 
806
                        
 
807
                        int i1 = result.Text.LastIndexOf ("typeof");
 
808
                        int i2 = result.Text.LastIndexOf ("(") + "(".Length;
 
809
                        Assert.AreEqual (@"typeof (", result.GetText (i1, i2 - i1));
 
810
                }
 
811
 
 
812
                [Test]
 
813
                public void TestWithinCheckedExpressionParanthesesSpace ()
 
814
                {
 
815
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
816
                        policy.SpacesWithinCheckedExpressionParantheses = true;
 
817
                        
 
818
                        var result = GetResult (policy, @"class Test {
 
819
        void TestMe ()
 
820
        {
 
821
                a = checked(a + b);
 
822
        }
 
823
}");
 
824
                        int i1 = result.Text.LastIndexOf ("(");
 
825
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
826
                        Assert.AreEqual (@"( a + b )", result.GetText (i1, i2 - i1));
 
827
                        
 
828
                        result = GetResult (policy, @"class Test {
 
829
        void TestMe ()
 
830
        {
 
831
                a = unchecked(a + b);
 
832
        }
 
833
}");
 
834
                        
 
835
                        result = GetResult (policy, result.Text);
 
836
                        i1 = result.Text.LastIndexOf ("(");
 
837
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
838
                        Assert.AreEqual (@"( a + b )", result.GetText (i1, i2 - i1));
 
839
                }
 
840
 
 
841
                [Test]
 
842
                public void TestSpaceBeforeNewParentheses ()
 
843
                {
 
844
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
845
                        policy.SpaceBeforeNewParentheses = true;
 
846
                        
 
847
                        var result = GetResult (policy, @"class Test {
 
848
        void TestMe ()
 
849
        {
 
850
                new Test();
 
851
        }
 
852
}");
 
853
                        int i1 = result.Text.LastIndexOf ("new");
 
854
                        int i2 = result.Text.LastIndexOf (";") + ";".Length;
 
855
                        Assert.AreEqual (@"new Test ();", result.GetText (i1, i2 - i1));
 
856
                }
 
857
 
 
858
                [Test]
 
859
                public void TestWithinNewParentheses ()
 
860
                {
 
861
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
862
                        policy.SpacesWithinNewParentheses = true;
 
863
                        
 
864
                        var result = GetResult (policy, @"class Test {
 
865
        void TestMe ()
 
866
        {
 
867
                new Test (1);
 
868
        }
 
869
}");
 
870
                        int i1 = result.Text.LastIndexOf ("new");
 
871
                        int i2 = result.Text.LastIndexOf (";") + ";".Length;
 
872
                        Assert.AreEqual (@"new Test ( 1 );", result.GetText (i1, i2 - i1));
 
873
                }
 
874
 
 
875
                [Test]
 
876
                public void TestBetweenEmptyNewParentheses ()
 
877
                {
 
878
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
879
                        policy.SpacesBetweenEmptyNewParentheses = true;
 
880
                        
 
881
                        var result = GetResult (policy, @"class Test {
 
882
        void TestMe ()
 
883
        {
 
884
                new Test ();
 
885
        }
 
886
}");
 
887
                        int i1 = result.Text.LastIndexOf ("new");
 
888
                        int i2 = result.Text.LastIndexOf (";") + ";".Length;
 
889
                        Assert.AreEqual (@"new Test ( );", result.GetText (i1, i2 - i1));
 
890
                }
 
891
 
 
892
                [Test]
 
893
                public void TestBeforeNewParameterComma ()
 
894
                {
 
895
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
896
                        policy.SpaceBeforeNewParameterComma = true;
 
897
                        policy.SpaceAfterNewParameterComma = false;
 
898
                        
 
899
                        var result = GetResult (policy, @"class Test {
 
900
        void TestMe ()
 
901
        {
 
902
                new Test (1,2);
 
903
        }
 
904
}");
 
905
                        int i1 = result.Text.LastIndexOf ("new");
 
906
                        int i2 = result.Text.LastIndexOf (";") + ";".Length;
 
907
                        Assert.AreEqual (@"new Test (1 ,2);", result.GetText (i1, i2 - i1));
 
908
                }
 
909
 
 
910
                [Test]
 
911
                public void TestAfterNewParameterComma ()
 
912
                {
 
913
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
914
                        policy.SpaceAfterNewParameterComma = true;
 
915
                        
 
916
                        var result = GetResult (policy, @"class Test {
 
917
        void TestMe ()
 
918
        {
 
919
                new Test (1,2);
 
920
        }
 
921
}");
 
922
                        int i1 = result.Text.LastIndexOf ("new");
 
923
                        int i2 = result.Text.LastIndexOf (";") + ";".Length;
 
924
                        Assert.AreEqual (@"new Test (1, 2);", result.GetText (i1, i2 - i1));
 
925
                }
 
926
 
 
927
                [Test]
 
928
                public void TestFieldDeclarationComma ()
 
929
                {
 
930
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
931
                        policy.SpaceBeforeFieldDeclarationComma = false;
 
932
                        policy.SpaceAfterFieldDeclarationComma = true;
 
933
                        
 
934
                        var result = GetResult (policy, @"class Test {
 
935
        int a,b,c;
 
936
}");
 
937
                        int i1 = result.Text.LastIndexOf ("int");
 
938
                        int i2 = result.Text.LastIndexOf (";") + ";".Length;
 
939
                        Assert.AreEqual (@"int a, b, c;", result.GetText (i1, i2 - i1));
 
940
                        policy.SpaceBeforeFieldDeclarationComma = true;
 
941
                        
 
942
                        result = GetResult (policy, result.Text);
 
943
                        i1 = result.Text.LastIndexOf ("int");
 
944
                        i2 = result.Text.LastIndexOf (";") + ";".Length;
 
945
                        Assert.AreEqual (@"int a , b , c;", result.GetText (i1, i2 - i1));
 
946
                        
 
947
                        policy.SpaceBeforeFieldDeclarationComma = false;
 
948
                        policy.SpaceAfterFieldDeclarationComma = false;
 
949
                        result = GetResult (policy, result.Text);
 
950
                        i1 = result.Text.LastIndexOf ("int");
 
951
                        i2 = result.Text.LastIndexOf (";") + ";".Length;
 
952
                        Assert.AreEqual (@"int a,b,c;", result.GetText (i1, i2 - i1));
 
953
                }
 
954
 
 
955
                [Test]
 
956
                public void TestBeforeMethodDeclarationParameterComma ()
 
957
                {
 
958
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
959
                        policy.SpaceBeforeMethodDeclarationParameterComma = true;
 
960
                        policy.SpaceAfterMethodDeclarationParameterComma = false;
 
961
                        
 
962
                        var result = GetResult (policy, @"class Test {
 
963
        public void Foo (int a,int b,int c) {}
 
964
}");
 
965
                        int i1 = result.Text.LastIndexOf ("(");
 
966
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
967
                        Assert.AreEqual (@"(int a ,int b ,int c)", result.GetText (i1, i2 - i1));
 
968
                        
 
969
                        policy.SpaceBeforeMethodDeclarationParameterComma = false;
 
970
                        result = GetResult (policy, result.Text);
 
971
                        i1 = result.Text.LastIndexOf ("(");
 
972
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
973
                        Assert.AreEqual (@"(int a,int b,int c)", result.GetText (i1, i2 - i1));
 
974
                }
 
975
 
 
976
                [Test]
 
977
                public void TestAfterMethodDeclarationParameterComma ()
 
978
                {
 
979
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
980
                        policy.SpaceBeforeMethodDeclarationParameterComma = false;
 
981
                        policy.SpaceAfterMethodDeclarationParameterComma = true;
 
982
                        
 
983
                        var result = GetResult (policy, @"class Test {
 
984
        public void Foo (int a,int b,int c) {}
 
985
}");
 
986
                        int i1 = result.Text.LastIndexOf ("(");
 
987
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
988
                        Assert.AreEqual (@"(int a, int b, int c)", result.GetText (i1, i2 - i1));
 
989
                        
 
990
                        policy.SpaceAfterMethodDeclarationParameterComma = false;
 
991
                        result = GetResult (policy, result.Text);
 
992
                        i1 = result.Text.LastIndexOf ("(");
 
993
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
994
                        Assert.AreEqual (@"(int a,int b,int c)", result.GetText (i1, i2 - i1));
 
995
                }
 
996
 
 
997
                [Test]
 
998
                public void TestSpacesInLambdaExpression ()
 
999
                {
 
1000
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1001
                        policy.SpacesWithinWhileParentheses = true;
 
1002
                        
 
1003
                        var result = GetResult (policy, @"class Test {
 
1004
        void TestMe ()
 
1005
        {
 
1006
                var v = x=>x!=null;
 
1007
        }
 
1008
}");
 
1009
                        int i1 = result.Text.IndexOf ("x");
 
1010
                        int i2 = result.Text.LastIndexOf ("null") + "null".Length;
 
1011
                        Assert.AreEqual (@"x => x != null", result.GetText (i1, i2 - i1));
 
1012
                }
 
1013
 
 
1014
                [Test]
 
1015
                public void TestBeforeLocalVariableDeclarationComma ()
 
1016
                {
 
1017
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1018
                        policy.SpaceBeforeLocalVariableDeclarationComma = true;
 
1019
                        policy.SpaceAfterLocalVariableDeclarationComma = false;
 
1020
 
 
1021
                        var result = GetResult (policy, @"class Test {
 
1022
        void TestMe ()
 
1023
        {
 
1024
                int a,b,c;
 
1025
        }
 
1026
}");
 
1027
                        int i1 = result.Text.IndexOf ("int");
 
1028
                        int i2 = result.Text.IndexOf (";") + ";".Length;
 
1029
                        Assert.AreEqual (@"int a ,b ,c;", result.GetText (i1, i2 - i1));
 
1030
 
 
1031
                        result = GetResult (policy, result.Text);
 
1032
 
 
1033
                        policy.SpaceBeforeLocalVariableDeclarationComma = false;
 
1034
 
 
1035
                        result = GetResult (policy, result.Text);
 
1036
                        i1 = result.Text.IndexOf ("int");
 
1037
                        i2 = result.Text.IndexOf (";") + ";".Length;
 
1038
                        Assert.AreEqual (@"int a,b,c;", result.GetText (i1, i2 - i1));
 
1039
                }
 
1040
 
 
1041
                [Test]
 
1042
                public void TestLocalVariableDeclarationComma ()
 
1043
                {
 
1044
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1045
                        policy.SpaceBeforeLocalVariableDeclarationComma = true;
 
1046
                        policy.SpaceAfterLocalVariableDeclarationComma = true;
 
1047
 
 
1048
                        var result = GetResult (policy, @"class Test {
 
1049
        void TestMe ()
 
1050
        {
 
1051
                int a = 5,b = 6,c;
 
1052
        }
 
1053
}");
 
1054
                        int i1 = result.Text.IndexOf ("int");
 
1055
                        int i2 = result.Text.IndexOf (";") + ";".Length;
 
1056
                        Assert.AreEqual (@"int a = 5 , b = 6 , c;", result.GetText (i1, i2 - i1));
 
1057
 
 
1058
                        result = GetResult (policy, result.Text);
 
1059
 
 
1060
                        policy.SpaceBeforeLocalVariableDeclarationComma = false;
 
1061
                        policy.SpaceAfterLocalVariableDeclarationComma = false;
 
1062
 
 
1063
                        result = GetResult (policy, result.Text);
 
1064
                        i1 = result.Text.IndexOf ("int");
 
1065
                        i2 = result.Text.IndexOf (";") + ";".Length;
 
1066
                        Assert.AreEqual (@"int a = 5,b = 6,c;", result.GetText (i1, i2 - i1));
 
1067
                }
 
1068
                
 
1069
                [Test]
 
1070
                public void TestLocalVariableWithGenerics ()
 
1071
                {
 
1072
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1073
                        policy.SpaceBeforeLocalVariableDeclarationComma = true;
 
1074
                        policy.SpaceAfterLocalVariableDeclarationComma = true;
 
1075
 
 
1076
                        var result = GetResult (policy, @"class Test {
 
1077
        void TestMe ()
 
1078
        {
 
1079
                List<Test> a;
 
1080
        }
 
1081
}");
 
1082
                        int i1 = result.Text.IndexOf ("List");
 
1083
                        int i2 = result.Text.IndexOf (";") + ";".Length;
 
1084
                        Assert.AreEqual (@"List<Test> a;", result.GetText (i1, i2 - i1));
 
1085
 
 
1086
                }
 
1087
 
 
1088
                #region Constructors
 
1089
                
 
1090
                [Test]
 
1091
                public void TestBeforeConstructorDeclarationParentheses ()
 
1092
                {
 
1093
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1094
                        policy.SpaceBeforeConstructorDeclarationParentheses = true;
 
1095
                        
 
1096
                        var result = GetResult (policy, @"class Test
 
1097
{
 
1098
        Test()
 
1099
        {
 
1100
        }
 
1101
}");
 
1102
                        
 
1103
                        Assert.AreEqual (NormalizeNewlines(@"class Test
 
1104
{
 
1105
        Test ()
 
1106
        {
 
1107
        }
 
1108
}"), result.Text);
 
1109
                }
 
1110
 
 
1111
                [Test]
 
1112
                public void TestBeforeConstructorDeclarationParameterComma ()
 
1113
                {
 
1114
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1115
                        policy.SpaceBeforeConstructorDeclarationParameterComma = true;
 
1116
                        policy.SpaceAfterConstructorDeclarationParameterComma = false;
 
1117
                        
 
1118
                        var result = GetResult (policy, @"class Test {
 
1119
        public Test (int a,int b,int c) {}
 
1120
}");
 
1121
                        
 
1122
                        int i1 = result.Text.LastIndexOf ("(");
 
1123
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1124
                        Assert.AreEqual (@"(int a ,int b ,int c)", result.GetText (i1, i2 - i1));
 
1125
                        
 
1126
                        policy.SpaceBeforeConstructorDeclarationParameterComma = false;
 
1127
                        result = GetResult (policy, result.Text);
 
1128
                        
 
1129
                        i1 = result.Text.LastIndexOf ("(");
 
1130
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1131
                        Assert.AreEqual (@"(int a,int b,int c)", result.GetText (i1, i2 - i1));
 
1132
                }
 
1133
 
 
1134
                [Test]
 
1135
                public void TestAfterConstructorDeclarationParameterComma ()
 
1136
                {
 
1137
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1138
                        policy.SpaceBeforeConstructorDeclarationParameterComma = false;
 
1139
                        policy.SpaceAfterConstructorDeclarationParameterComma = true;
 
1140
                        
 
1141
                        var result = GetResult (policy, @"class Test {
 
1142
        public Test (int a,int b,int c) {}
 
1143
}");
 
1144
                        int i1 = result.Text.LastIndexOf ("(");
 
1145
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1146
                        Assert.AreEqual (@"(int a, int b, int c)", result.GetText (i1, i2 - i1));
 
1147
                        
 
1148
                        policy.SpaceAfterConstructorDeclarationParameterComma = false;
 
1149
                        result = GetResult (policy, result.Text);
 
1150
                        i1 = result.Text.LastIndexOf ("(");
 
1151
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1152
                        Assert.AreEqual (@"(int a,int b,int c)", result.GetText (i1, i2 - i1));
 
1153
                }
 
1154
 
 
1155
                [Test]
 
1156
                public void TestWithinConstructorDeclarationParentheses ()
 
1157
                {
 
1158
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1159
                        policy.SpaceWithinConstructorDeclarationParentheses = true;
 
1160
                        
 
1161
                        var result = GetResult (policy, @"class Test {
 
1162
        Test (int a)
 
1163
        {
 
1164
        }
 
1165
}");
 
1166
                        int i1 = result.Text.LastIndexOf ("(");
 
1167
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1168
                        Assert.AreEqual (@"( int a )", result.GetText (i1, i2 - i1));
 
1169
                }
 
1170
 
 
1171
                [Test]
 
1172
                public void TestBetweenEmptyConstructorDeclarationParentheses ()
 
1173
                {
 
1174
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1175
                        policy.SpaceBetweenEmptyConstructorDeclarationParentheses = true;
 
1176
                        
 
1177
                        var result = GetResult (policy, @"class Test {
 
1178
        Test ()
 
1179
        {
 
1180
        }
 
1181
}");
 
1182
                        int i1 = result.Text.LastIndexOf ("(");
 
1183
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1184
                        Assert.AreEqual (@"( )", result.GetText (i1, i2 - i1));
 
1185
                }
 
1186
 
 
1187
                #endregion
 
1188
                
 
1189
                #region Delegates
 
1190
                [Test]
 
1191
                public void TestBeforeDelegateDeclarationParentheses ()
 
1192
                {
 
1193
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1194
                        policy.SpaceBeforeDelegateDeclarationParentheses = true;
 
1195
                        
 
1196
                        var result = GetResult (policy, @"delegate void Test();");
 
1197
                        
 
1198
                        Assert.AreEqual (@"delegate void Test ();", result.Text);
 
1199
                }
 
1200
 
 
1201
                [Test]
 
1202
                public void TestBeforeDelegateDeclarationParenthesesComplex ()
 
1203
                {
 
1204
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1205
                        policy.SpaceBeforeDelegateDeclarationParentheses = true;
 
1206
                        
 
1207
                        var result = GetResult (policy, "delegate void TestDelegate\t\t\t();");
 
1208
                        
 
1209
                        Assert.AreEqual (@"delegate void TestDelegate ();", result.Text);
 
1210
                }
 
1211
 
 
1212
                [Test]
 
1213
                public void TestBeforeDelegateDeclarationParameterComma ()
 
1214
                {
 
1215
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1216
                        policy.SpaceBeforeDelegateDeclarationParameterComma = true;
 
1217
                        policy.SpaceAfterDelegateDeclarationParameterComma = false;
 
1218
                        
 
1219
                        var result = GetResult (policy, @"delegate void Test (int a,int b,int c);");
 
1220
                        
 
1221
                        int i1 = result.Text.LastIndexOf ("(");
 
1222
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1223
                        Assert.AreEqual (@"(int a ,int b ,int c)", result.GetText (i1, i2 - i1));
 
1224
                        
 
1225
                        policy.SpaceBeforeDelegateDeclarationParameterComma = false;
 
1226
                        result = GetResult (policy, result.Text);
 
1227
                        i1 = result.Text.LastIndexOf ("(");
 
1228
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1229
                        Assert.AreEqual (@"(int a,int b,int c)", result.GetText (i1, i2 - i1));
 
1230
                }
 
1231
 
 
1232
                [Test]
 
1233
                public void TestAfterDelegateDeclarationParameterComma ()
 
1234
                {
 
1235
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1236
                        policy.SpaceBeforeDelegateDeclarationParameterComma = false;
 
1237
                        policy.SpaceAfterDelegateDeclarationParameterComma = true;
 
1238
                        
 
1239
                        var result = GetResult (policy, @"delegate void Test (int a,int b,int c);");
 
1240
                        
 
1241
                        int i1 = result.Text.LastIndexOf ("(");
 
1242
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1243
                        Assert.AreEqual (@"(int a, int b, int c)", result.GetText (i1, i2 - i1));
 
1244
                        
 
1245
                        policy.SpaceAfterDelegateDeclarationParameterComma = false;
 
1246
                        result = GetResult (policy, result.Text);
 
1247
                        i1 = result.Text.LastIndexOf ("(");
 
1248
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1249
                        Assert.AreEqual (@"(int a,int b,int c)", result.GetText (i1, i2 - i1));
 
1250
                }
 
1251
 
 
1252
                [Test]
 
1253
                public void TestWithinDelegateDeclarationParentheses ()
 
1254
                {
 
1255
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1256
                        policy.SpaceWithinDelegateDeclarationParentheses = true;
 
1257
                        var result = GetResult (policy, @"delegate void Test (int a);");
 
1258
                        
 
1259
                        int i1 = result.Text.LastIndexOf ("(");
 
1260
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1261
                        Assert.AreEqual (@"( int a )", result.GetText (i1, i2 - i1));
 
1262
                }
 
1263
 
 
1264
                [Test]
 
1265
                public void TestBetweenEmptyDelegateDeclarationParentheses ()
 
1266
                {
 
1267
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1268
                        policy.SpaceBetweenEmptyDelegateDeclarationParentheses = true;
 
1269
                        var result = GetResult (policy, @"delegate void Test();");
 
1270
                        
 
1271
                        int i1 = result.Text.LastIndexOf ("(");
 
1272
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1273
                        Assert.AreEqual (@"( )", result.GetText (i1, i2 - i1));
 
1274
                }
 
1275
 
 
1276
                #endregion
 
1277
                
 
1278
                #region Method invocations
 
1279
                [Test]
 
1280
                public void TestBeforeMethodCallParentheses ()
 
1281
                {
 
1282
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1283
                        policy.SpaceBeforeMethodCallParentheses = true;
 
1284
                        
 
1285
                        var result = GetResult (policy, @"class FooBar
 
1286
{
 
1287
        public void Foo ()
 
1288
        {
 
1289
                Test();
 
1290
        }
 
1291
}");
 
1292
                        
 
1293
                        Assert.AreEqual (NormalizeNewlines(@"class FooBar
 
1294
{
 
1295
        public void Foo ()
 
1296
        {
 
1297
                Test ();
 
1298
        }
 
1299
}"), result.Text);
 
1300
                }
 
1301
 
 
1302
                [Test]
 
1303
                public void TestBeforeMethodCallParameterComma ()
 
1304
                {
 
1305
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1306
                        policy.SpaceBeforeMethodCallParameterComma = true;
 
1307
                        policy.SpaceAfterMethodCallParameterComma = false;
 
1308
                        
 
1309
                        var result = GetResult (policy, @"class FooBar
 
1310
{
 
1311
        public void Foo ()
 
1312
        {
 
1313
                Test(a,b,c);
 
1314
        }
 
1315
}");
 
1316
                        int i1 = result.Text.LastIndexOf ("(");
 
1317
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1318
                        Assert.AreEqual (@"(a ,b ,c)", result.GetText (i1, i2 - i1));
 
1319
                        
 
1320
                        policy.SpaceBeforeMethodCallParameterComma = false;
 
1321
                        result = GetResult (policy, result.Text);
 
1322
                        i1 = result.Text.LastIndexOf ("(");
 
1323
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1324
                        Assert.AreEqual (@"(a,b,c)", result.GetText (i1, i2 - i1));
 
1325
                }
 
1326
 
 
1327
                [Test]
 
1328
                public void TestAfterMethodCallParameterComma ()
 
1329
                {
 
1330
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1331
                        policy.SpaceBeforeMethodCallParameterComma = false;
 
1332
                        policy.SpaceAfterMethodCallParameterComma = true;
 
1333
                        
 
1334
                        var result = GetResult (policy, @"class FooBar
 
1335
{
 
1336
        public void Foo ()
 
1337
        {
 
1338
                Test(a,b,c);
 
1339
        }
 
1340
}");
 
1341
                        int i1 = result.Text.LastIndexOf ("(");
 
1342
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1343
                        Assert.AreEqual (@"(a, b, c)", result.GetText (i1, i2 - i1));
 
1344
                        
 
1345
                        policy.SpaceAfterMethodCallParameterComma = false;
 
1346
                        result = GetResult (policy, result.Text);
 
1347
                        i1 = result.Text.LastIndexOf ("(");
 
1348
                        i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1349
                        Assert.AreEqual (@"(a,b,c)", result.GetText (i1, i2 - i1));
 
1350
                }
 
1351
 
 
1352
                [Test]
 
1353
                public void TestWithinMethodCallParentheses ()
 
1354
                {
 
1355
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1356
                        policy.SpaceWithinMethodCallParentheses = true;
 
1357
                        
 
1358
                        var result = GetResult (policy, @"class FooBar
 
1359
{
 
1360
        public void Foo ()
 
1361
        {
 
1362
                Test(a);
 
1363
        }
 
1364
}");
 
1365
                        int i1 = result.Text.LastIndexOf ("(");
 
1366
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1367
                        Assert.AreEqual (@"( a )", result.GetText (i1, i2 - i1));
 
1368
                }
 
1369
 
 
1370
                [Test]
 
1371
                public void TestBetweenEmptyMethodCallParentheses ()
 
1372
                {
 
1373
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1374
                        policy.SpaceBetweenEmptyMethodCallParentheses = true;
 
1375
                        
 
1376
                        var result = GetResult (policy, @"class FooBar
 
1377
{
 
1378
        public void Foo ()
 
1379
        {
 
1380
                Test();
 
1381
        }
 
1382
}");
 
1383
                        int i1 = result.Text.LastIndexOf ("(");
 
1384
                        int i2 = result.Text.LastIndexOf (")") + ")".Length;
 
1385
                        Assert.AreEqual (@"( )", result.GetText (i1, i2 - i1));
 
1386
                }
 
1387
 
 
1388
                #endregion
 
1389
                
 
1390
                #region Indexer declarations
 
1391
                [Test]
 
1392
                public void TestBeforeIndexerDeclarationBracket ()
 
1393
                {
 
1394
                        
 
1395
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1396
                        policy.SpaceBeforeIndexerDeclarationBracket = true;
 
1397
                        
 
1398
                        var result = GetResult (policy, @"class FooBar
 
1399
{
 
1400
        public int this[int a, int b] {
 
1401
                get {
 
1402
                        return a + b;   
 
1403
                }
 
1404
        }
 
1405
}");
 
1406
                        Assert.AreEqual (NormalizeNewlines(@"class FooBar
 
1407
{
 
1408
        public int this [int a, int b] {
 
1409
                get {
 
1410
                        return a + b;   
 
1411
                }
 
1412
        }
 
1413
}"), result.Text);
 
1414
                }
 
1415
 
 
1416
                [Test]
 
1417
                public void TestBeforeIndexerDeclarationParameterComma ()
 
1418
                {
 
1419
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1420
                        policy.SpaceBeforeIndexerDeclarationParameterComma = true;
 
1421
                        policy.SpaceAfterIndexerDeclarationParameterComma = false;
 
1422
                        
 
1423
                        var result = GetResult (policy, @"class FooBar
 
1424
{
 
1425
        public int this[int a,int b] {
 
1426
                get {
 
1427
                        return a + b;   
 
1428
                }
 
1429
        }
 
1430
}");
 
1431
                        int i1 = result.Text.LastIndexOf ("[");
 
1432
                        int i2 = result.Text.LastIndexOf ("]") + "]".Length;
 
1433
                        Assert.AreEqual (@"[int a ,int b]", result.GetText (i1, i2 - i1));
 
1434
 
 
1435
                }
 
1436
 
 
1437
                [Test]
 
1438
                public void TestAfterIndexerDeclarationParameterComma ()
 
1439
                {
 
1440
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1441
                        policy.SpaceAfterIndexerDeclarationParameterComma = true;
 
1442
                        
 
1443
                        var result = GetResult (policy, @"class FooBar
 
1444
{
 
1445
        public int this[int a,int b] {
 
1446
                get {
 
1447
                        return a + b;   
 
1448
                }
 
1449
        }
 
1450
}");
 
1451
                        int i1 = result.Text.LastIndexOf ("[");
 
1452
                        int i2 = result.Text.LastIndexOf ("]") + "]".Length;
 
1453
                        Assert.AreEqual (@"[int a, int b]", result.GetText (i1, i2 - i1));
 
1454
                }
 
1455
 
 
1456
                [Test]
 
1457
                public void TestWithinIndexerDeclarationBracket ()
 
1458
                {
 
1459
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1460
                        policy.SpaceWithinIndexerDeclarationBracket = true;
 
1461
                        
 
1462
                        var result = GetResult (policy, @"class FooBar
 
1463
{
 
1464
        public int this[int a, int b] {
 
1465
                get {
 
1466
                        return a + b;   
 
1467
                }
 
1468
        }
 
1469
}");
 
1470
                        int i1 = result.Text.LastIndexOf ("[");
 
1471
                        int i2 = result.Text.LastIndexOf ("]") + "]".Length;
 
1472
                        Assert.AreEqual (@"[ int a, int b ]", result.GetText (i1, i2 - i1));
 
1473
                }
 
1474
 
 
1475
                #endregion
 
1476
 
 
1477
                #region Brackets
 
1478
                
 
1479
                [Test]
 
1480
                public void TestSpacesWithinBrackets ()
 
1481
                {
 
1482
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1483
                        policy.SpacesWithinBrackets = true;
 
1484
                        policy.SpacesBeforeBrackets = false;
 
1485
                        
 
1486
                        var result = GetResult (policy, @"class Test
 
1487
{
 
1488
        void TestMe ()
 
1489
        {
 
1490
                this[0] = 5;
 
1491
        }
 
1492
}");
 
1493
                        Assert.AreEqual (NormalizeNewlines(@"class Test
 
1494
{
 
1495
        void TestMe ()
 
1496
        {
 
1497
                this[ 0 ] = 5;
 
1498
        }
 
1499
}"), result.Text);
 
1500
                        
 
1501
                        
 
1502
                }
 
1503
 
 
1504
                [Test]
 
1505
                public void TestSpacesBeforeBrackets ()
 
1506
                {
 
1507
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1508
                        policy.SpacesBeforeBrackets = true;
 
1509
                        
 
1510
                        var result = GetResult (policy, @"class Test
 
1511
{
 
1512
        void TestMe ()
 
1513
        {
 
1514
                this[0] = 5;
 
1515
        }
 
1516
}");
 
1517
                        Assert.AreEqual (NormalizeNewlines(@"class Test
 
1518
{
 
1519
        void TestMe ()
 
1520
        {
 
1521
                this [0] = 5;
 
1522
        }
 
1523
}"), result.Text);
 
1524
                        
 
1525
                        
 
1526
                }
 
1527
 
 
1528
                [Test]
 
1529
                public void TestBeforeBracketComma ()
 
1530
                {
 
1531
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1532
                        policy.SpaceBeforeBracketComma = true;
 
1533
                        policy.SpaceAfterBracketComma = false;
 
1534
                        
 
1535
                        var result = GetResult (policy, @"class Test {
 
1536
        void TestMe ()
 
1537
        {
 
1538
                this[1,2,3] = 5;
 
1539
        }
 
1540
}");
 
1541
                        
 
1542
                        int i1 = result.Text.LastIndexOf ("[");
 
1543
                        int i2 = result.Text.LastIndexOf ("]") + "]".Length;
 
1544
                        Assert.AreEqual (@"[1 ,2 ,3]", result.GetText (i1, i2 - i1));
 
1545
                }
 
1546
 
 
1547
                [Test]
 
1548
                public void TestAfterBracketComma ()
 
1549
                {
 
1550
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1551
                        policy.SpaceAfterBracketComma = true;
 
1552
                        
 
1553
                        var result = GetResult (policy, @"class Test {
 
1554
        void TestMe ()
 
1555
        {
 
1556
                this[1,2,3] = 5;
 
1557
        }
 
1558
}");
 
1559
                        
 
1560
                        int i1 = result.Text.LastIndexOf ("[");
 
1561
                        int i2 = result.Text.LastIndexOf ("]") + "]".Length;
 
1562
                        Assert.AreEqual (@"[1, 2, 3]", result.GetText (i1, i2 - i1));
 
1563
                }
 
1564
 
 
1565
                #endregion
 
1566
                
 
1567
                [Test]
 
1568
                public void TestSpacesBeforeArrayDeclarationBrackets ()
 
1569
                {
 
1570
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1571
                        policy.SpaceBeforeArrayDeclarationBrackets = true;
 
1572
                        
 
1573
                        var result = GetResult (policy, @"class Test
 
1574
{
 
1575
        int[] a;
 
1576
        int[][] b;
 
1577
}");
 
1578
                        
 
1579
                        Assert.AreEqual (NormalizeNewlines(@"class Test
 
1580
{
 
1581
        int [] a;
 
1582
        int [][] b;
 
1583
}"), result.Text);
 
1584
                        
 
1585
                        
 
1586
                }
 
1587
 
 
1588
                [Test]
 
1589
                public void TestRemoveWhitespacesBeforeSemicolon()
 
1590
                {
 
1591
                        CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
 
1592
                        var result = GetResult(policy, @"class Test {
 
1593
        void TestMe ()
 
1594
        {
 
1595
                Foo ()        ;
 
1596
        }
 
1597
}");
 
1598
                        int i1 = result.Text.IndexOf("Foo");
 
1599
                        int i2 = result.Text.LastIndexOf(";") + ";".Length;
 
1600
                        Assert.AreEqual(@"Foo ();", result.GetText(i1, i2 - i1));
 
1601
                }
 
1602
 
 
1603
                [Test]
 
1604
                public void TestSpaceInNamedArgumentAfterDoubleColon()
 
1605
                {
 
1606
                        var policy = FormattingOptionsFactory.CreateMono ();
 
1607
                        policy.SpaceInNamedArgumentAfterDoubleColon = true;
 
1608
                        var result = GetResult(policy, @"class Test {
 
1609
        void TestMe ()
 
1610
        {
 
1611
                Foo (bar:expr);
 
1612
        }
 
1613
}");
 
1614
                        int i1 = result.Text.IndexOf("Foo");
 
1615
                        int i2 = result.Text.LastIndexOf(";") + ";".Length;
 
1616
                        Assert.AreEqual(@"Foo (bar: expr);", result.GetText(i1, i2 - i1));
 
1617
                }
 
1618
 
 
1619
                [Test]
 
1620
                public void TestSpaceInNamedArgumentAfterDoubleColon2()
 
1621
                {
 
1622
                        var policy = FormattingOptionsFactory.CreateMono ();
 
1623
                        policy.SpaceInNamedArgumentAfterDoubleColon = false;
 
1624
                        var result = GetResult(policy, @"class Test {
 
1625
        void TestMe ()
 
1626
        {
 
1627
                Foo (bar:                      expr);
 
1628
        }
 
1629
}");
 
1630
                        int i1 = result.Text.IndexOf("Foo");
 
1631
                        int i2 = result.Text.LastIndexOf(";") + ";".Length;
 
1632
                        Assert.AreEqual(@"Foo (bar:expr);", result.GetText(i1, i2 - i1));
 
1633
                }
 
1634
 
 
1635
 
 
1636
 
 
1637
 
 
1638
 
 
1639
                
 
1640
        }
 
1641
}