main
cs 53 lines 2.35 KB
Raw
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.Linq;
7 using System.Xml.Linq;
8 using WixInternal.TestSupport;
9 using WixToolset.Converters;
10 using WixToolsetTest.Converters.Mocks;
11 using Xunit;
12
13 public class BalConditionFixture : BaseConverterFixture
14 {
15 [Fact]
16 public void CanConvertActionToLowercase()
17 {
18 var parse = String.Join(Environment.NewLine,
19 "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs' xmlns:bal='http://schemas.microsoft.com/wix/BalExtension'>",
20 " <Fragment>",
21 " <bal:Condition Message='Example message.'>WixBundleInstalled OR NOT (VersionNT = v6.1) OR (VersionNT = v6.1 AND ServicePackLevel = 1)</bal:Condition>",
22 " </Fragment>",
23 "</Wix>");
24
25 var expected = new[]
26 {
27 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:bal=\"http://wixtoolset.org/schemas/v4/wxs/bal\">",
28 " <Fragment>",
29 " <bal:Condition Message=\"Example message.\" Condition=\"WixBundleInstalled OR NOT (VersionNT = v6.1) OR (VersionNT = v6.1 AND ServicePackLevel = 1)\" />",
30 " </Fragment>",
31 "</Wix>"
32 };
33
34 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
35
36 var messaging = new MockMessaging();
37 var converter = new WixConverter(messaging, 2, null, null);
38
39 var errors = converter.ConvertDocument(document);
40
41 var actualLines = UnformattedDocumentLines(document);
42 WixAssert.CompareLineByLine(expected, actualLines);
43
44 WixAssert.CompareLineByLine(new[]
45 {
46 "[Converted] The namespace 'http://schemas.microsoft.com/wix/BalExtension' is out of date. It must be 'http://wixtoolset.org/schemas/v4/wxs/bal'. (XmlnsValueWrong)",
47 "[Converted] Using Condition element text is deprecated. Use the 'Condition' attribute instead. (InnerTextDeprecated)",
48 }, messaging.Messages.Select(m => m.ToString()).ToArray());
49
50 Assert.Equal(2, errors);
51 }
52 }
53 }