main
cs 61 lines 2.84 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 RelatedBundleFixture : 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'>",
20 " <Fragment>",
21 " <RelatedBundle Id='D' Action='Detect' />",
22 " <RelatedBundle Id='U' Action='Upgrade' />",
23 " <RelatedBundle Id='A' Action='Addon' />",
24 " <RelatedBundle Id='P' Action='Patch' />",
25 " </Fragment>",
26 "</Wix>");
27
28 var expected = new[]
29 {
30 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
31 " <Fragment>",
32 " <RelatedBundle Id=\"D\" Action=\"detect\" />",
33 " <RelatedBundle Id=\"U\" Action=\"upgrade\" />",
34 " <RelatedBundle Id=\"A\" Action=\"addon\" />",
35 " <RelatedBundle Id=\"P\" Action=\"patch\" />",
36 " </Fragment>",
37 "</Wix>"
38 };
39
40 var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
41
42 var messaging = new MockMessaging();
43 var converter = new WixConverter(messaging, 2, null, null);
44
45 var errors = converter.ConvertDocument(document);
46
47 var actualLines = UnformattedDocumentLines(document);
48 WixAssert.CompareLineByLine(expected, actualLines);
49
50 WixAssert.CompareLineByLine(new[]
51 {
52 "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Detect' will be converted to 'detect' (RelatedBundleActionLowercase)",
53 "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Upgrade' will be converted to 'upgrade' (RelatedBundleActionLowercase)",
54 "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Addon' will be converted to 'addon' (RelatedBundleActionLowercase)",
55 "[Converted] The RelatedBundle element's Action attribute value must now be all lowercase. The Action='Patch' will be converted to 'patch' (RelatedBundleActionLowercase)",
56 }, messaging.Messages.Select(m => m.ToString()).ToArray());
57
58 Assert.Equal(4, errors);
59 }
60 }
61 }