1
1
using System . Collections . Generic ;
2
2
using Microsoft . Test . Apex . Editor ;
3
- using Microsoft . Test . Apex . VisualStudio . Solution ;
4
3
using Microsoft . VisualStudio . TestTools . UnitTesting ;
5
4
6
5
namespace Microsoft . Web . LibraryManager . IntegrationTest
7
6
{
8
7
[ TestClass ]
9
8
public class LibmanCompletionTests : VisualStudioLibmanHostTest
10
9
{
11
- ProjectItemTestExtension _libManConfig ;
12
-
13
- [ TestInitialize ( ) ]
14
- public void initialize ( )
15
- {
16
- string projectName = "TestProjectCore20" ;
17
-
18
- ProjectTestExtension webProject = Solution . ProjectsRecursive [ projectName ] ;
19
- _libManConfig = webProject . Find ( SolutionItemFind . FileName , "libman.json" ) ;
20
- }
21
-
22
10
[ TestMethod ]
23
11
public void LibmanCompletion_Destination ( )
24
12
{
25
- _libManConfig . Open ( ) ;
13
+ _libmanConfig . Open ( ) ;
26
14
string [ ] expectedCompletionEntries = new [ ] {
27
15
"Properties/" ,
28
16
"wwwroot/" ,
29
17
} ;
30
18
31
19
Editor . Caret . MoveToExpression ( "\" libraries\" " ) ;
32
- Editor . Caret . MoveDown ( 2 ) ;
20
+ Editor . Caret . MoveDown ( 1 ) ;
21
+ Editor . KeyboardCommands . Type ( "{" ) ;
22
+ Editor . KeyboardCommands . Enter ( ) ;
33
23
Editor . KeyboardCommands . Type ( "\" destination\" :" ) ;
34
24
35
25
Helpers . Completion . WaitForCompletionEntries ( Editor , expectedCompletionEntries , caseInsensitive : true ) ;
@@ -38,7 +28,7 @@ public void LibmanCompletion_Destination()
38
28
[ TestMethod ]
39
29
public void LibmanCompletion_Provider ( )
40
30
{
41
- _libManConfig . Open ( ) ;
31
+ _libmanConfig . Open ( ) ;
42
32
43
33
string [ ] expectedCompletionEntries = new [ ] {
44
34
"cdnjs" ,
@@ -47,7 +37,9 @@ public void LibmanCompletion_Provider()
47
37
} ;
48
38
49
39
Editor . Caret . MoveToExpression ( "\" libraries\" " ) ;
50
- Editor . Caret . MoveDown ( 2 ) ;
40
+ Editor . Caret . MoveDown ( 1 ) ;
41
+ Editor . KeyboardCommands . Type ( "{" ) ;
42
+ Editor . KeyboardCommands . Enter ( ) ;
51
43
Editor . KeyboardCommands . Type ( "\" provider\" :" ) ;
52
44
53
45
Helpers . Completion . WaitForCompletionEntries ( Editor , expectedCompletionEntries , caseInsensitive : true ) ;
@@ -56,7 +48,7 @@ public void LibmanCompletion_Provider()
56
48
[ TestMethod ]
57
49
public void LibmanCompletion_DefaultProvider ( )
58
50
{
59
- _libManConfig . Open ( ) ;
51
+ _libmanConfig . Open ( ) ;
60
52
61
53
string [ ] expectedCompletionEntries = new [ ] {
62
54
"cdnjs" ,
@@ -75,7 +67,7 @@ public void LibmanCompletion_DefaultProvider()
75
67
[ TestMethod ]
76
68
public void LibmanCompletion_DefaultDestination ( )
77
69
{
78
- _libManConfig . Open ( ) ;
70
+ _libmanConfig . Open ( ) ;
79
71
string [ ] expectedCompletionEntries = new [ ] {
80
72
"Properties/" ,
81
73
"wwwroot/" ,
@@ -92,13 +84,15 @@ public void LibmanCompletion_DefaultDestination()
92
84
[ TestMethod ]
93
85
public void LibmanCompletion_LibraryForCdnjs ( )
94
86
{
95
- _libManConfig . Open ( ) ;
87
+ _libmanConfig . Open ( ) ;
96
88
string [ ] expectedCompletionEntries = new [ ] {
97
89
"jquery" ,
98
90
} ;
99
91
100
92
Editor . Caret . MoveToExpression ( "\" libraries\" " ) ;
101
- Editor . Caret . MoveDown ( 2 ) ;
93
+ Editor . Caret . MoveDown ( 1 ) ;
94
+ Editor . KeyboardCommands . Type ( "{" ) ;
95
+ Editor . KeyboardCommands . Enter ( ) ;
102
96
Editor . KeyboardCommands . Type ( "\" provider\" : \" cdnjs\" ," ) ;
103
97
Editor . KeyboardCommands . Enter ( ) ;
104
98
@@ -109,10 +103,12 @@ public void LibmanCompletion_LibraryForCdnjs()
109
103
[ TestMethod ]
110
104
public void LibmanCompletion_LibraryVersionForCdnjs ( )
111
105
{
112
- _libManConfig . Open ( ) ;
106
+ _libmanConfig . Open ( ) ;
113
107
114
108
Editor . Caret . MoveToExpression ( "\" libraries\" " ) ;
115
- Editor . Caret . MoveDown ( 2 ) ;
109
+ Editor . Caret . MoveDown ( 1 ) ;
110
+ Editor . KeyboardCommands . Type ( "{" ) ;
111
+ Editor . KeyboardCommands . Enter ( ) ;
116
112
Editor . KeyboardCommands . Type ( "\" provider\" : \" cdnjs\" ," ) ;
117
113
Editor . KeyboardCommands . Enter ( ) ;
118
114
@@ -126,14 +122,16 @@ public void LibmanCompletion_LibraryVersionForCdnjs()
126
122
[ TestMethod ]
127
123
public void LibmanCompletion_LibraryForFilesystem ( )
128
124
{
129
- _libManConfig . Open ( ) ;
125
+ _libmanConfig . Open ( ) ;
130
126
string [ ] expectedCompletionEntries = new [ ] {
131
127
"Properties/" ,
132
128
"wwwroot/" ,
133
129
} ;
134
130
135
131
Editor . Caret . MoveToExpression ( "\" libraries\" " ) ;
136
- Editor . Caret . MoveDown ( 2 ) ;
132
+ Editor . Caret . MoveDown ( 1 ) ;
133
+ Editor . KeyboardCommands . Type ( "{" ) ;
134
+ Editor . KeyboardCommands . Enter ( ) ;
137
135
Editor . KeyboardCommands . Type ( "\" provider\" : \" filesystem\" ," ) ;
138
136
Editor . KeyboardCommands . Enter ( ) ;
139
137
@@ -144,28 +142,34 @@ public void LibmanCompletion_LibraryForFilesystem()
144
142
[ TestMethod ]
145
143
public void LibmanCompletion_LibraryForUnpkg ( )
146
144
{
147
- _libManConfig . Open ( ) ;
148
- string [ ] expectedCompletionEntries = new [ ] {
149
- "bootstrap" ,
150
- "jquery" ,
151
- } ;
145
+ // This test needs to be updated once we fix https://github.com/aspnet/LibraryManager/issues/221
146
+ _libmanConfig . Open ( ) ;
152
147
153
148
Editor . Caret . MoveToExpression ( "\" libraries\" " ) ;
154
- Editor . Caret . MoveDown ( 2 ) ;
149
+ Editor . Caret . MoveDown ( 1 ) ;
150
+ Editor . KeyboardCommands . Type ( "{" ) ;
151
+ Editor . KeyboardCommands . Enter ( ) ;
155
152
Editor . KeyboardCommands . Type ( "\" provider\" : \" unpkg\" ," ) ;
156
153
Editor . KeyboardCommands . Enter ( ) ;
157
154
158
155
Editor . KeyboardCommands . Type ( "\" library\" :" ) ;
159
- Helpers . Completion . WaitForCompletionEntries ( Editor , expectedCompletionEntries , caseInsensitive : true , timeout : 5000 ) ;
156
+ Editor . KeyboardCommands . Type ( "bootstr" ) ;
157
+ Helpers . Completion . WaitForCompletionEntries ( Editor , new [ ] { "bootstrap" } , caseInsensitive : true , timeout : 5000 ) ;
158
+
159
+ Editor . KeyboardCommands . Backspace ( 7 ) ;
160
+ Editor . KeyboardCommands . Type ( "jqu" ) ;
161
+ Helpers . Completion . WaitForCompletionEntries ( Editor , new [ ] { "jquery" } , caseInsensitive : true , timeout : 5000 ) ;
160
162
}
161
163
162
164
[ TestMethod ]
163
165
public void LibmanCompletion_CompletionForBackSpace ( )
164
166
{
165
- _libManConfig . Open ( ) ;
167
+ _libmanConfig . Open ( ) ;
166
168
167
169
Editor . Caret . MoveToExpression ( "\" libraries\" " ) ;
168
- Editor . Caret . MoveDown ( 2 ) ;
170
+ Editor . Caret . MoveDown ( 1 ) ;
171
+ Editor . KeyboardCommands . Type ( "{" ) ;
172
+ Editor . KeyboardCommands . Enter ( ) ;
169
173
Editor . KeyboardCommands . Type ( "\" provider\" : \" cdnjs\" ," ) ;
170
174
Editor . KeyboardCommands . Enter ( ) ;
171
175
@@ -179,10 +183,12 @@ public void LibmanCompletion_CompletionForBackSpace()
179
183
[ TestMethod ]
180
184
public void LibmanCompletion_VersionCompletionInDescendingOrder ( )
181
185
{
182
- _libManConfig . Open ( ) ;
186
+ _libmanConfig . Open ( ) ;
183
187
184
188
Editor . Caret . MoveToExpression ( "\" libraries\" " ) ;
185
- Editor . Caret . MoveDown ( 2 ) ;
189
+ Editor . Caret . MoveDown ( 1 ) ;
190
+ Editor . KeyboardCommands . Type ( "{" ) ;
191
+ Editor . KeyboardCommands . Enter ( ) ;
186
192
Editor . KeyboardCommands . Type ( "\" provider\" : \" unpkg\" ," ) ;
187
193
Editor . KeyboardCommands . Enter ( ) ;
188
194
@@ -200,7 +206,7 @@ public void LibmanCompletion_VersionCompletionInDescendingOrder()
200
206
semanticVersions . Add ( SemanticVersion . Parse ( item . Text ) ) ;
201
207
}
202
208
203
- for ( int i = 1 ; i < semanticVersions . Count ; ++ i )
209
+ for ( int i = 1 ; i < semanticVersions . Count ; ++ i )
204
210
{
205
211
Assert . IsTrue ( semanticVersions [ i ] . CompareTo ( semanticVersions [ i - 1 ] ) <= 0 ) ;
206
212
}
0 commit comments