main
cs 60 lines 2.71 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 MsuPackageFixture : BaseConverterFixture
14 {
15 [Fact]
16 public void CanRemoveMsuPackageDeprecatedAttributes()
17 {
18 var parse = String.Join(Environment.NewLine,
19 "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>",
20 " <Fragment>",
21 " <PackageGroup Id='msu'>",
22 " <MsuPackage Id='PermanentMsuPackage' KB='1234' Permanent='yes' DetectCondition='none'>",
23 " <MsuPackagePayload DownloadUrl='example.com' SourceFile='ignored.msu' />",
24 " </MsuPackage>",
25 " </PackageGroup>",
26 " </Fragment>",
27 "</Wix>");
28
29 var expected = new[]
30 {
31 "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
32 " <Fragment>",
33 " <PackageGroup Id=\"msu\">",
34 " <MsuPackage Id=\"PermanentMsuPackage\" DetectCondition=\"none\">",
35 " <MsuPackagePayload DownloadUrl=\"example.com\" SourceFile=\"ignored.msu\" />",
36 " </MsuPackage>",
37 " </PackageGroup>",
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
49 var actualLines = UnformattedDocumentLines(document);
50 WixAssert.CompareLineByLine(new[]
51 {
52 "[Converted] The MsuPackage element contains obsolete 'KB' attribute. Windows no longer supports silently removing MSUs so the attribute is unnecessary. The attribute will be removed. (MsuPackageKBObsolete)",
53 "[Converted] The MsuPackage element contains obsolete 'Permanent' attribute. MSU packages are now always permanent because Windows no longer supports silently removing MSUs. The attribute will be removed. (MsuPackagePermanentObsolete)",
54 }, messaging.Messages.Select(m => m.ToString()).ToArray());
55 WixAssert.CompareLineByLine(expected, actualLines);
56
57 Assert.Equal(2, errors);
58 }
59 }
60 }