aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2018-10-04 13:54:59 -0700
committerBob Arnson <bob@firegiant.com>2018-10-04 18:20:52 -0400
commit784208bd46ce05025d8ccaef8542328350038d90 (patch)
tree595db4df20b8681fe613c5bd176c0c5c866bc1f4 /src/test
parenteb4e0c543148f70a0c442d829848a3e3e1d33a91 (diff)
downloadwix-784208bd46ce05025d8ccaef8542328350038d90.tar.gz
wix-784208bd46ce05025d8ccaef8542328350038d90.tar.bz2
wix-784208bd46ce05025d8ccaef8542328350038d90.zip
Simplify whitespace handling and fix some long standing bugs in it
Fixes wixtoolset/issues#5883
Diffstat (limited to 'src/test')
-rw-r--r--src/test/WixToolsetTest.WixCop/ConverterFixture.cs74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.WixCop/ConverterFixture.cs b/src/test/WixToolsetTest.WixCop/ConverterFixture.cs
index 86931d5a..863a781a 100644
--- a/src/test/WixToolsetTest.WixCop/ConverterFixture.cs
+++ b/src/test/WixToolsetTest.WixCop/ConverterFixture.cs
@@ -94,8 +94,82 @@ namespace WixToolsetTest.WixCop
94 94
95 var actual = UnformattedDocumentString(document); 95 var actual = UnformattedDocumentString(document);
96 96
97 Assert.Equal(expected, actual);
97 Assert.Equal(4, errors); 98 Assert.Equal(4, errors);
99 }
100
101 [Fact]
102 public void CanPreserveNewLines()
103 {
104 var parse = String.Join(Environment.NewLine,
105 "<?xml version='1.0' encoding='utf-8'?>",
106 "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>",
107 " <Fragment>",
108 "",
109 " <Property Id='Prop' Value='Val' />",
110 "",
111 " </Fragment>",
112 "</Wix>");
113
114 var expected = String.Join(Environment.NewLine,
115 "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
116 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
117 " <Fragment>",
118 "",
119 " <Property Id=\"Prop\" Value=\"Val\" />",
120 "",
121 " </Fragment>",
122 "</Wix>");
123
124 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
125
126 var messaging = new DummyMessaging();
127 var converter = new Converter(messaging, 4, null, null);
128
129 var conversions = converter.ConvertDocument(document);
130
131 var actual = UnformattedDocumentString(document);
132
133 Assert.Equal(expected, actual);
134 Assert.Equal(3, conversions);
135 }
136
137 [Fact]
138 public void CanConvertWithNewLineAtEndOfFile()
139 {
140 var parse = String.Join(Environment.NewLine,
141 "<?xml version='1.0' encoding='utf-8'?>",
142 "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>",
143 " <Fragment>",
144 "",
145 " <Property Id='Prop' Value='Val' />",
146 "",
147 " </Fragment>",
148 "</Wix>",
149 "");
150
151 var expected = String.Join(Environment.NewLine,
152 "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
153 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
154 " <Fragment>",
155 "",
156 " <Property Id=\"Prop\" Value=\"Val\" />",
157 "",
158 " </Fragment>",
159 "</Wix>",
160 "");
161
162 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
163
164 var messaging = new DummyMessaging();
165 var converter = new Converter(messaging, 4, null, null);
166
167 var conversions = converter.ConvertDocument(document);
168
169 var actual = UnformattedDocumentString(document);
170
98 Assert.Equal(expected, actual); 171 Assert.Equal(expected, actual);
172 Assert.Equal(3, conversions);
99 } 173 }
100 174
101 [Fact] 175 [Fact]