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

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.Tests/CSharp/CodeActions/SortUsingsTests.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
using NUnit.Framework;
 
2
using ICSharpCode.NRefactory.CSharp.Refactoring;
 
3
 
 
4
namespace ICSharpCode.NRefactory.CSharp.CodeActions
 
5
{
 
6
        [TestFixture]
 
7
        public class SortUsingsTests : ContextActionTestBase
 
8
        {
 
9
                [Test]
 
10
                public void TestActiveWhenCursorAtUsing()
 
11
                {
 
12
                        Test<SortUsingsAction>(@"using Sys$tem.Linq;
 
13
using System;", @"using System;
 
14
using System.Linq;");
 
15
                }
 
16
 
 
17
                [Test]
 
18
                public void TestActiveWhenCursorBehindUsing()
 
19
                {
 
20
                        Test<SortUsingsAction>(@"using System.Linq;$
 
21
using System;", @"using System;
 
22
using System.Linq;");
 
23
                }
 
24
 
 
25
                [Test]
 
26
                public void TestInActiveWhenCursorOutsideUsings()
 
27
                {
 
28
                        TestWrongContext<SortUsingsAction>(@"using System.Linq;
 
29
using System;
 
30
$");
 
31
                }
 
32
 
 
33
                [Test]
 
34
                public void TestSortsAllUsingBlocksInFile()
 
35
                {
 
36
                        Test<SortUsingsAction>(@"using $System.Linq;
 
37
using System;
 
38
 
 
39
namespace Foo
 
40
{
 
41
        using System.IO;
 
42
        using System.Collections;
 
43
}
 
44
 
 
45
namespace Bar
 
46
{
 
47
        using System.IO;
 
48
        using System.Runtime;
 
49
        using System.Diagnostics;
 
50
}", @"using System;
 
51
using System.Linq;
 
52
 
 
53
namespace Foo
 
54
{
 
55
        using System.Collections;
 
56
        using System.IO;
 
57
}
 
58
 
 
59
namespace Bar
 
60
{
 
61
        using System.Diagnostics;
 
62
        using System.IO;
 
63
        using System.Runtime;
 
64
}");
 
65
                }
 
66
 
 
67
                [Test]
 
68
                public void TestAliasesGoesToTheEnd()
 
69
                {
 
70
                        Test<SortUsingsAction>(@"$using Sys = System;
 
71
using System;", @"using System;
 
72
using Sys = System;");
 
73
                }
 
74
 
 
75
                [Test]
 
76
                public void TestUnknownNamespacesGoesAfterKnownOnes()
 
77
                {
 
78
                        Test<SortUsingsAction>(@"$using Foo;
 
79
using System;", @"using System;
 
80
using Foo;");
 
81
                }
 
82
 
 
83
                [Test]
 
84
                public void TestMixedStuff()
 
85
                {
 
86
                        Test<SortUsingsAction>(@"$using Foo;
 
87
using System.Linq;
 
88
using Sys = System;
 
89
using System;
 
90
using FooAlias = Foo;
 
91
using Linq = System.Linq;", @"using System;
 
92
using System.Linq;
 
93
using Foo;
 
94
using Linq = System.Linq;
 
95
using Sys = System;
 
96
using FooAlias = Foo;");
 
97
                }
 
98
 
 
99
                [Test]
 
100
                public void TestPreservesEmptyLinesWhichIsInFactABug()
 
101
                {
 
102
                        Test<SortUsingsAction>(@"$using System.Linq;
 
103
 
 
104
using System;", @"using System;
 
105
 
 
106
using System.Linq;");
 
107
                }
 
108
                
 
109
                
 
110
                [Test]
 
111
                public void TestPreservesPreprocessorDirectives()
 
112
                {
 
113
                        Test<SortUsingsAction>(@"$using D;
 
114
using A;
 
115
#if true
 
116
using C;
 
117
using B;
 
118
#endif", @"using A;
 
119
using D;
 
120
#if true
 
121
using B;
 
122
using C;
 
123
#endif");
 
124
                }
 
125
        }
 
126
}