aboutsummaryrefslogtreecommitdiff
path: root/src/wix/test/WixToolsetTest.Converters/DirectoryFixture.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wix/test/WixToolsetTest.Converters/DirectoryFixture.cs')
-rw-r--r--src/wix/test/WixToolsetTest.Converters/DirectoryFixture.cs78
1 files changed, 77 insertions, 1 deletions
diff --git a/src/wix/test/WixToolsetTest.Converters/DirectoryFixture.cs b/src/wix/test/WixToolsetTest.Converters/DirectoryFixture.cs
index c938b9ad..f4cb3b6d 100644
--- a/src/wix/test/WixToolsetTest.Converters/DirectoryFixture.cs
+++ b/src/wix/test/WixToolsetTest.Converters/DirectoryFixture.cs
@@ -94,7 +94,7 @@ namespace WixToolsetTest.Converters
94 "[Converted] This file contains an XML declaration on the first line. (DeclarationPresent)", 94 "[Converted] This file contains an XML declaration on the first line. (DeclarationPresent)",
95 "[Converted] The namespace 'http://schemas.microsoft.com/wix/2006/wi' is out of date. It must be 'http://wixtoolset.org/schemas/v4/wxs'. (XmlnsValueWrong)", 95 "[Converted] The namespace 'http://schemas.microsoft.com/wix/2006/wi' is out of date. It must be 'http://wixtoolset.org/schemas/v4/wxs'. (XmlnsValueWrong)",
96 "[Converted] The TARGETDIR directory should no longer be explicitly referenced. Remove the DirectoryRef element with Id attribute 'TARGETDIR'. (StandardDirectoryRefDeprecated)", 96 "[Converted] The TARGETDIR directory should no longer be explicitly referenced. Remove the DirectoryRef element with Id attribute 'TARGETDIR'. (StandardDirectoryRefDeprecated)",
97 "A reference to the TARGETDIR Directory was removed. This may cause the Fragment that defined TARGETDIR to not be included in the final output. If this happens, reference a different element in the Fragment to replace the old reference to TARGEDIR. (TargetDirRefRemoved)", 97 "A reference to the TARGETDIR Directory was removed. This can cause unintended side effects. See the conversion FAQ for more information: https://wixtoolset.org/docs/fourthree/faqs/#converting-packages (TargetDirRefRemoved)",
98 }, messaging.Messages.Select(m => m.ToString()).ToArray()); 98 }, messaging.Messages.Select(m => m.ToString()).ToArray());
99 Assert.Equal(4, errors); 99 Assert.Equal(4, errors);
100 } 100 }
@@ -212,6 +212,82 @@ namespace WixToolsetTest.Converters
212 } 212 }
213 213
214 [Fact] 214 [Fact]
215 public void RemoveTargetDirWithComponents()
216 {
217 var parse = String.Join(Environment.NewLine,
218 "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
219 "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
220 " <Fragment>",
221 " <DirectoryRef Id='TARGETDIR'>",
222 " <Component Id='C1'>",
223 " <File Source='c1.txt' />",
224 " </Component>",
225 " <Component Id='C2'>",
226 " <File Source='c2.txt' />",
227 " </Component>",
228 " </DirectoryRef>",
229 " </Fragment>",
230 " <Fragment>",
231 " <Directory Id='TARGETDIR'>",
232 " <Component Id='C3'>",
233 " <File Source='c3.txt' />",
234 " </Component>",
235 " <Component Id='C4' Directory='PreExisting'>",
236 " <File Source='c4.txt' />",
237 " </Component>",
238 " </Directory>",
239 " </Fragment>",
240 "</Wix>");
241
242 var expected = new[]
243 {
244 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
245 " <Fragment>",
246 " <Component Id=\"C1\" Directory=\"TARGETDIR\">",
247 " <File Id=\"c1.txt\" Source=\"c1.txt\" />",
248 " </Component>",
249 " <Component Id=\"C2\" Directory=\"TARGETDIR\">",
250 " <File Id=\"c2.txt\" Source=\"c2.txt\" />",
251 " </Component>",
252 " </Fragment>",
253 " <Fragment>",
254 " <Component Id=\"C3\" Directory=\"TARGETDIR\">",
255 " <File Id=\"c3.txt\" Source=\"c3.txt\" />",
256 " </Component>",
257 " <Component Id=\"C4\" Directory=\"PreExisting\">",
258 " <File Id=\"c4.txt\" Source=\"c4.txt\" />",
259 " </Component>",
260 " </Fragment>",
261 "</Wix>"
262 };
263
264 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
265
266 var messaging = new MockMessaging();
267 var converter = new WixConverter(messaging, 2, null, null);
268
269 var errors = converter.ConvertDocument(document);
270
271 var actualLines = UnformattedDocumentLines(document);
272 WixAssert.CompareLineByLine(expected, actualLines);
273
274 WixAssert.CompareLineByLine(new[]
275 {
276 "[Converted] This file contains an XML declaration on the first line. (DeclarationPresent)",
277 "[Converted] The namespace 'http://schemas.microsoft.com/wix/2006/wi' is out of date. It must be 'http://wixtoolset.org/schemas/v4/wxs'. (XmlnsValueWrong)",
278 "[Converted] The TARGETDIR directory should no longer be explicitly referenced. Remove the DirectoryRef element with Id attribute 'TARGETDIR'. (StandardDirectoryRefDeprecated)",
279 "A reference to the TARGETDIR Directory was removed. This can cause unintended side effects. See the conversion FAQ for more information: https://wixtoolset.org/docs/fourthree/faqs/#converting-packages (TargetDirRefRemoved)",
280 "[Converted] The file id is being updated to 'c1.txt' to ensure it remains the same as the v3 default (AssignAnonymousFileId)",
281 "[Converted] The file id is being updated to 'c2.txt' to ensure it remains the same as the v3 default (AssignAnonymousFileId)",
282 "[Converted] The TARGETDIR directory should no longer be explicitly defined. Remove the Directory element with Id attribute 'TARGETDIR'. (TargetDirDeprecated)",
283 "[Converted] The file id is being updated to 'c3.txt' to ensure it remains the same as the v3 default (AssignAnonymousFileId)",
284 "[Converted] The file id is being updated to 'c4.txt' to ensure it remains the same as the v3 default (AssignAnonymousFileId)"
285 }, messaging.Messages.Select(m => m.ToString()).ToArray());
286
287 Assert.Equal(9, errors);
288 }
289
290 [Fact]
215 public void ErrorOnEmptyStandardDirectoryRef() 291 public void ErrorOnEmptyStandardDirectoryRef()
216 { 292 {
217 var parse = String.Join(Environment.NewLine, 293 var parse = String.Join(Environment.NewLine,