diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs b/src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs index bbae4636..55f54cc2 100644 --- a/src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs +++ b/src/wix/test/WixToolsetTest.Core/PreprocessorFixture.cs | |||
| @@ -107,6 +107,165 @@ namespace WixToolsetTest.Core | |||
| 107 | WixAssert.CompareLineByLine(expected, actual); | 107 | WixAssert.CompareLineByLine(expected, actual); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | [Fact] | ||
| 111 | public void CanPreprocessIfdefWithFullVariableSyntaxFalsy() | ||
| 112 | { | ||
| 113 | var input = String.Join(Environment.NewLine, | ||
| 114 | "<Wix>", | ||
| 115 | "<?ifdef $(A) ?>", | ||
| 116 | " <Fragment />", | ||
| 117 | "<?endif?>", | ||
| 118 | "</Wix>" | ||
| 119 | ); | ||
| 120 | var expected = new[] | ||
| 121 | { | ||
| 122 | "<Wix />" | ||
| 123 | }; | ||
| 124 | |||
| 125 | var result = PreprocessFromString(input); | ||
| 126 | |||
| 127 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 128 | WixAssert.CompareLineByLine(expected, actual); | ||
| 129 | } | ||
| 130 | |||
| 131 | [Fact] | ||
| 132 | public void CanPreprocessIfdefWithFullVariableSyntaxTruthy() | ||
| 133 | { | ||
| 134 | var input = String.Join(Environment.NewLine, | ||
| 135 | "<Wix>", | ||
| 136 | "<?define A?>", | ||
| 137 | "<?ifdef $(A) ?>", | ||
| 138 | " <Fragment />", | ||
| 139 | "<?endif?>", | ||
| 140 | "</Wix>" | ||
| 141 | ); | ||
| 142 | var expected = new[] | ||
| 143 | { | ||
| 144 | "<Wix>", | ||
| 145 | " <Fragment />", | ||
| 146 | "</Wix>" | ||
| 147 | }; | ||
| 148 | |||
| 149 | var result = PreprocessFromString(input); | ||
| 150 | |||
| 151 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 152 | WixAssert.CompareLineByLine(expected, actual); | ||
| 153 | } | ||
| 154 | |||
| 155 | [Fact] | ||
| 156 | public void CanPreprocessIfndefWithFullVariableSyntaxTruthy() | ||
| 157 | { | ||
| 158 | var input = String.Join(Environment.NewLine, | ||
| 159 | "<Wix>", | ||
| 160 | "<?ifndef $(A) ?>", | ||
| 161 | " <Fragment />", | ||
| 162 | "<?endif?>", | ||
| 163 | "</Wix>" | ||
| 164 | ); | ||
| 165 | var expected = new[] | ||
| 166 | { | ||
| 167 | "<Wix>", | ||
| 168 | " <Fragment />", | ||
| 169 | "</Wix>" | ||
| 170 | }; | ||
| 171 | |||
| 172 | var result = PreprocessFromString(input); | ||
| 173 | |||
| 174 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 175 | WixAssert.CompareLineByLine(expected, actual); | ||
| 176 | } | ||
| 177 | |||
| 178 | [Fact] | ||
| 179 | public void CanPreprocessIfndefWithFullVariableSyntaxFalsy() | ||
| 180 | { | ||
| 181 | var input = String.Join(Environment.NewLine, | ||
| 182 | "<Wix>", | ||
| 183 | "<?define A?>", | ||
| 184 | "<?ifndef $(A) ?>", | ||
| 185 | " <Fragment />", | ||
| 186 | "<?endif?>", | ||
| 187 | "</Wix>" | ||
| 188 | ); | ||
| 189 | var expected = new[] | ||
| 190 | { | ||
| 191 | "<Wix />" | ||
| 192 | }; | ||
| 193 | |||
| 194 | var result = PreprocessFromString(input); | ||
| 195 | |||
| 196 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 197 | WixAssert.CompareLineByLine(expected, actual); | ||
| 198 | } | ||
| 199 | |||
| 200 | [Fact] | ||
| 201 | public void CanPreprocessIfdefWithFullVariableV3SyntaxTruthy() | ||
| 202 | { | ||
| 203 | var input = String.Join(Environment.NewLine, | ||
| 204 | "<Wix>", | ||
| 205 | "<?define A?>", | ||
| 206 | "<?ifdef $(var.A) ?>", | ||
| 207 | " <Fragment />", | ||
| 208 | "<?endif?>", | ||
| 209 | "</Wix>" | ||
| 210 | ); | ||
| 211 | var expected = new[] | ||
| 212 | { | ||
| 213 | "<Wix>", | ||
| 214 | " <Fragment />", | ||
| 215 | "</Wix>" | ||
| 216 | }; | ||
| 217 | |||
| 218 | var result = PreprocessFromString(input); | ||
| 219 | |||
| 220 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 221 | WixAssert.CompareLineByLine(expected, actual); | ||
| 222 | } | ||
| 223 | |||
| 224 | [Fact] | ||
| 225 | public void CanPreprocessIfndefWithFullVariableV3SyntaxTruthy() | ||
| 226 | { | ||
| 227 | var input = String.Join(Environment.NewLine, | ||
| 228 | "<Wix>", | ||
| 229 | "<?ifndef $(var.A) ?>", | ||
| 230 | " <Fragment />", | ||
| 231 | "<?endif?>", | ||
| 232 | "</Wix>" | ||
| 233 | ); | ||
| 234 | var expected = new[] | ||
| 235 | { | ||
| 236 | "<Wix>", | ||
| 237 | " <Fragment />", | ||
| 238 | "</Wix>" | ||
| 239 | }; | ||
| 240 | |||
| 241 | var result = PreprocessFromString(input); | ||
| 242 | |||
| 243 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 244 | WixAssert.CompareLineByLine(expected, actual); | ||
| 245 | } | ||
| 246 | |||
| 247 | [Fact] | ||
| 248 | public void CanPreprocessIfndefWithFullVariableV3SyntaxFalsy() | ||
| 249 | { | ||
| 250 | var input = String.Join(Environment.NewLine, | ||
| 251 | "<Wix>", | ||
| 252 | "<?define A?>", | ||
| 253 | "<?ifndef $(var.A) ?>", | ||
| 254 | " <Fragment />", | ||
| 255 | "<?endif?>", | ||
| 256 | "</Wix>" | ||
| 257 | ); | ||
| 258 | var expected = new[] | ||
| 259 | { | ||
| 260 | "<Wix />" | ||
| 261 | }; | ||
| 262 | |||
| 263 | var result = PreprocessFromString(input); | ||
| 264 | |||
| 265 | var actual = result.Document.ToString().Split("\r\n"); | ||
| 266 | WixAssert.CompareLineByLine(expected, actual); | ||
| 267 | } | ||
| 268 | |||
| 110 | private static IPreprocessResult PreprocessFromString(string xml) | 269 | private static IPreprocessResult PreprocessFromString(string xml) |
| 111 | { | 270 | { |
| 112 | using var stringReader = new StringReader(xml); | 271 | using var stringReader = new StringReader(xml); |
