diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/WixToolsetTest.Converters/DirectoryFixture.cs | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.Converters/DirectoryFixture.cs b/src/test/WixToolsetTest.Converters/DirectoryFixture.cs new file mode 100644 index 00000000..3c906320 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/DirectoryFixture.cs | |||
@@ -0,0 +1,92 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolsetTest.Converters | ||
4 | { | ||
5 | using System; | ||
6 | using System.Xml.Linq; | ||
7 | using WixBuildTools.TestSupport; | ||
8 | using WixToolset.Converters; | ||
9 | using WixToolsetTest.Converters.Mocks; | ||
10 | using Xunit; | ||
11 | |||
12 | public class DirectoryFixture : BaseConverterFixture | ||
13 | { | ||
14 | [Fact] | ||
15 | public void RemoveTargetDir() | ||
16 | { | ||
17 | var parse = String.Join(Environment.NewLine, | ||
18 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
19 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
20 | " <Fragment>", | ||
21 | " <Directory Id='TARGETDIR' Name='SourceDir'>", | ||
22 | " <!-- Comment -->", | ||
23 | " <Directory Id='RootFolder' Name='Root'>", | ||
24 | " <Directory Id='ChildFolder' Name='Child' />", | ||
25 | " </Directory>", | ||
26 | " </Directory>", | ||
27 | " </Fragment>", | ||
28 | "</Wix>"); | ||
29 | |||
30 | var expected = new[] | ||
31 | { | ||
32 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
33 | " <Fragment>", | ||
34 | " <!-- Comment -->", | ||
35 | " <Directory Id=\"RootFolder\" Name=\"Root\">", | ||
36 | " <Directory Id=\"ChildFolder\" Name=\"Child\" />", | ||
37 | " </Directory>", | ||
38 | " </Fragment>", | ||
39 | "</Wix>" | ||
40 | }; | ||
41 | |||
42 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
43 | |||
44 | var messaging = new MockMessaging(); | ||
45 | var converter = new WixConverter(messaging, 2, null, null); | ||
46 | |||
47 | var errors = converter.ConvertDocument(document); | ||
48 | Assert.Equal(3, errors); | ||
49 | |||
50 | var actualLines = UnformattedDocumentLines(document); | ||
51 | WixAssert.CompareLineByLine(expected, actualLines); | ||
52 | } | ||
53 | |||
54 | [Fact] | ||
55 | public void FixStandardDirectory() | ||
56 | { | ||
57 | var parse = String.Join(Environment.NewLine, | ||
58 | "<?xml version=\"1.0\" encoding=\"utf-16\"?>", | ||
59 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", | ||
60 | " <Fragment>", | ||
61 | " <Directory Id='TARGETDIR' Name='SourceDir'>", | ||
62 | " <Directory Id='ProgramFilesFolder' Name='PFiles'>", | ||
63 | " <Directory Id='ChildFolder' Name='Child' />", | ||
64 | " </Directory>", | ||
65 | " </Directory>", | ||
66 | " </Fragment>", | ||
67 | "</Wix>"); | ||
68 | |||
69 | var expected = new[] | ||
70 | { | ||
71 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
72 | " <Fragment>", | ||
73 | " <StandardDirectory Id=\"ProgramFilesFolder\">", | ||
74 | " <Directory Id=\"ChildFolder\" Name=\"Child\" />", | ||
75 | " </StandardDirectory>", | ||
76 | " </Fragment>", | ||
77 | "</Wix>" | ||
78 | }; | ||
79 | |||
80 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
81 | |||
82 | var messaging = new MockMessaging(); | ||
83 | var converter = new WixConverter(messaging, 2, null, null); | ||
84 | |||
85 | var errors = converter.ConvertDocument(document); | ||
86 | Assert.Equal(4, errors); | ||
87 | |||
88 | var actualLines = UnformattedDocumentLines(document); | ||
89 | WixAssert.CompareLineByLine(expected, actualLines); | ||
90 | } | ||
91 | } | ||
92 | } | ||