1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
- using System ;
5
4
using System . IO ;
6
5
using System . Linq ;
7
6
using Microsoft . VisualStudio . TestTools . UnitTesting ;
@@ -35,16 +34,18 @@ public void TestInstall_CleanDirectory()
35
34
Assert . IsTrue ( File . Exists ( Path . Combine ( WorkingDir , "libman.json" ) ) ) ;
36
35
37
36
string text = File . ReadAllText ( Path . Combine ( WorkingDir , "libman.json" ) ) ;
38
- string expectedText = @"{
39
- ""version"": ""3.0"",
40
- ""defaultProvider"": ""cdnjs"",
41
- ""libraries"": [
42
- {
43
- ""library"": ""[email protected] "",
44
- ""destination"": ""wwwroot""
45
- }
46
- ]
47
- }" ;
37
+ string expectedText = """
38
+ {
39
+ "version": "3.0",
40
+ "defaultProvider": "cdnjs",
41
+ "libraries": [
42
+ {
43
+
44
+ "destination": "wwwroot"
45
+ }
46
+ ]
47
+ }
48
+ """ ;
48
49
Assert . AreEqual ( StringHelper . NormalizeNewLines ( expectedText ) , StringHelper . NormalizeNewLines ( text ) ) ;
49
50
}
50
51
@@ -63,16 +64,18 @@ public void TestInstall_CleanDirectory_WithPromptForProvider()
63
64
Assert . IsTrue ( File . Exists ( Path . Combine ( WorkingDir , "libman.json" ) ) ) ;
64
65
65
66
string text = File . ReadAllText ( Path . Combine ( WorkingDir , "libman.json" ) ) ;
66
- string expectedText = @"{
67
- ""version"": ""3.0"",
68
- ""defaultProvider"": ""cdnjs"",
69
- ""libraries"": [
70
- {
71
- ""library"": ""[email protected] "",
72
- ""destination"": ""wwwroot""
73
- }
74
- ]
75
- }" ;
67
+ string expectedText = """
68
+ {
69
+ "version": "3.0",
70
+ "defaultProvider": "cdnjs",
71
+ "libraries": [
72
+ {
73
+
74
+ "destination": "wwwroot"
75
+ }
76
+ ]
77
+ }
78
+ """ ;
76
79
Assert . AreEqual ( StringHelper . NormalizeNewLines ( expectedText ) , StringHelper . NormalizeNewLines ( text ) ) ;
77
80
}
78
81
@@ -83,11 +86,13 @@ public void TestInstall_ExistingLibman_WithPromptForProvider()
83
86
84
87
testInputReader . Inputs . Add ( "ProviderId" , "cdnjs" ) ;
85
88
86
- string initialContent = @"{
87
- ""version"": ""1.0"",
88
- ""libraries"": [
89
- ]
90
- }" ;
89
+ string initialContent = """
90
+ {
91
+ "version": "1.0",
92
+ "libraries": [
93
+ ]
94
+ }
95
+ """ ;
91
96
92
97
File . WriteAllText ( Path . Combine ( WorkingDir , "libman.json" ) , initialContent ) ;
93
98
var command = new InstallCommand ( HostEnvironment ) ;
@@ -98,16 +103,18 @@ public void TestInstall_ExistingLibman_WithPromptForProvider()
98
103
Assert . IsTrue ( File . Exists ( Path . Combine ( WorkingDir , "libman.json" ) ) ) ;
99
104
100
105
string text = File . ReadAllText ( Path . Combine ( WorkingDir , "libman.json" ) ) ;
101
- string expectedText = @"{
102
- ""version"": ""1.0"",
103
- ""defaultProvider"": ""cdnjs"",
104
- ""libraries"": [
105
- {
106
- ""library"": ""[email protected] "",
107
- ""destination"": ""wwwroot""
108
- }
109
- ]
110
- }" ;
106
+ string expectedText = """
107
+ {
108
+ "version": "1.0",
109
+ "defaultProvider": "cdnjs",
110
+ "libraries": [
111
+ {
112
+
113
+ "destination": "wwwroot"
114
+ }
115
+ ]
116
+ }
117
+ """ ;
111
118
Assert . AreEqual ( StringHelper . NormalizeNewLines ( expectedText ) , StringHelper . NormalizeNewLines ( text ) ) ;
112
119
}
113
120
@@ -118,13 +125,15 @@ public void TestInstall_WithExistingLibmanJson()
118
125
var command = new InstallCommand ( HostEnvironment ) ;
119
126
command . Configure ( null ) ;
120
127
121
- string initialContent = @"{
122
- ""version"": ""1.0"",
123
- ""defaultProvider"": ""cdnjs"",
124
- ""defaultDestination"": ""wwwroot"",
125
- ""libraries"": [
126
- ]
127
- }" ;
128
+ string initialContent = """
129
+ {
130
+ "version": "1.0",
131
+ "defaultProvider": "cdnjs",
132
+ "defaultDestination": "wwwroot",
133
+ "libraries": [
134
+ ]
135
+ }
136
+ """ ;
128
137
129
138
File . WriteAllText ( Path . Combine ( WorkingDir , "libman.json" ) , initialContent ) ;
130
139
@@ -133,16 +142,18 @@ public void TestInstall_WithExistingLibmanJson()
133
142
Assert . IsTrue ( File . Exists ( Path . Combine ( WorkingDir , "libman.json" ) ) ) ;
134
143
135
144
string actualText = File . ReadAllText ( Path . Combine ( WorkingDir , "libman.json" ) ) ;
136
- string expectedText = @"{
137
- ""version"": ""1.0"",
138
- ""defaultProvider"": ""cdnjs"",
139
- ""defaultDestination"": ""wwwroot"",
140
- ""libraries"": [
141
- {
142
- ""library"": ""[email protected] ""
143
- }
144
- ]
145
- }" ;
145
+ string expectedText = """
146
+ {
147
+ "version": "1.0",
148
+ "defaultProvider": "cdnjs",
149
+ "defaultDestination": "wwwroot",
150
+ "libraries": [
151
+ {
152
+
153
+ }
154
+ ]
155
+ }
156
+ """ ;
146
157
Assert . AreEqual ( StringHelper . NormalizeNewLines ( expectedText ) , StringHelper . NormalizeNewLines ( actualText ) ) ;
147
158
}
148
159
@@ -152,16 +163,18 @@ public void TestInstall_Duplicate()
152
163
var command = new InstallCommand ( HostEnvironment ) ;
153
164
command . Configure ( null ) ;
154
165
155
- string initialContent = @"{
156
- ""version"": ""1.0"",
157
- ""defaultProvider"": ""cdnjs"",
158
- ""defaultDestination"": ""wwwroot"",
159
- ""libraries"": [
160
- {
161
- ""library"": ""[email protected] ""
162
- }
163
- ]
164
- }" ;
166
+ string initialContent = """
167
+ {
168
+ "version": "1.0",
169
+ "defaultProvider": "cdnjs",
170
+ "defaultDestination": "wwwroot",
171
+ "libraries": [
172
+ {
173
+
174
+ }
175
+ ]
176
+ }
177
+ """ ;
165
178
166
179
File . WriteAllText ( Path . Combine ( WorkingDir , "libman.json" ) , initialContent ) ;
167
180
@@ -177,33 +190,37 @@ public void TestInstall_WithExistingLibmanJson_SpecificFiles()
177
190
var command = new InstallCommand ( HostEnvironment ) ;
178
191
command . Configure ( null ) ;
179
192
180
- string initialContent = @"{
181
- ""version"": ""1.0"",
182
- ""defaultProvider"": ""cdnjs"",
183
- ""defaultDestination"": ""wwwroot"",
184
- ""libraries"": [
185
- ]
186
- }" ;
193
+ string initialContent = """
194
+ {
195
+ "version": "1.0",
196
+ "defaultProvider": "cdnjs",
197
+ "defaultDestination": "wwwroot",
198
+ "libraries": [
199
+ ]
200
+ }
201
+ """ ;
187
202
188
203
File . WriteAllText ( Path . Combine ( WorkingDir , "libman.json" ) , initialContent ) ;
189
204
command . Execute ( "[email protected] " , "--files" , "jquery.min.js" ) ;
190
205
191
206
Assert . IsTrue ( File . Exists ( Path . Combine ( WorkingDir , "libman.json" ) ) ) ;
192
207
193
208
string actualText = File . ReadAllText ( Path . Combine ( WorkingDir , "libman.json" ) ) ;
194
- string expectedText = @"{
195
- ""version"": ""1.0"",
196
- ""defaultProvider"": ""cdnjs"",
197
- ""defaultDestination"": ""wwwroot"",
198
- ""libraries"": [
199
- {
200
- ""library"": ""[email protected] "",
201
- ""files"": [
202
- ""jquery.min.js""
203
- ]
204
- }
205
- ]
206
- }" ;
209
+ string expectedText = """
210
+ {
211
+ "version": "1.0",
212
+ "defaultProvider": "cdnjs",
213
+ "defaultDestination": "wwwroot",
214
+ "libraries": [
215
+ {
216
+
217
+ "files": [
218
+ "jquery.min.js"
219
+ ]
220
+ }
221
+ ]
222
+ }
223
+ """ ;
207
224
Assert . AreEqual ( StringHelper . NormalizeNewLines ( expectedText ) , StringHelper . NormalizeNewLines ( actualText ) ) ;
208
225
}
209
226
@@ -213,18 +230,22 @@ public void TestInstall_WithInvalidFiles()
213
230
var command = new InstallCommand ( HostEnvironment ) ;
214
231
command . Configure ( null ) ;
215
232
216
- string initialContent = @"{
217
- ""version"": ""1.0"",
218
- ""defaultProvider"": ""cdnjs"",
219
- ""defaultDestination"": ""wwwroot"",
220
- ""libraries"": [
221
- ]
222
- }" ;
233
+ string initialContent = """
234
+ {
235
+ "version": "1.0",
236
+ "defaultProvider": "cdnjs",
237
+ "defaultDestination": "wwwroot",
238
+ "libraries": [
239
+ ]
240
+ }
241
+ """ ;
223
242
224
243
File . WriteAllText ( Path . Combine ( WorkingDir , "libman.json" ) , initialContent ) ;
225
244
command . Execute ( "[email protected] " , "--files" , "abc.js" ) ;
226
- string expectedMessage = @"[LIB018]: ""[email protected] "" does not contain the following: abc.js
227
- Valid files are jquery.js, jquery.min.js, jquery.min.map, jquery.slim.js, jquery.slim.min.js, jquery.slim.min.map" ;
245
+ string expectedMessage = """
246
+ [LIB018]: "[email protected] " does not contain the following: abc.js
247
+ Valid files are jquery.js, jquery.min.js, jquery.min.map, jquery.slim.js, jquery.slim.min.js, jquery.slim.min.map
248
+ """ ;
228
249
229
250
var logger = HostEnvironment . Logger as TestLogger ;
230
251
Assert . AreEqual ( expectedMessage , logger . Messages . Last ( ) . Value ) ;
0 commit comments