| 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.Xml.Linq; |
| 7 | using WixInternal.TestSupport; |
| 8 | using WixToolset.Converters; |
| 9 | using WixToolsetTest.Converters.Mocks; |
| 10 | using Xunit; |
| 11 | |
| 12 | public class RemotePayloadFixture : BaseConverterFixture |
| 13 | { |
| 14 | [Fact] |
| 15 | public void CanConvertExePackageRemotePayload() |
| 16 | { |
| 17 | var parse = String.Join(Environment.NewLine, |
| 18 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
| 19 | " <Fragment>", |
| 20 | " <PackageGroup Id='exe'>", |
| 21 | " <ExePackage Name='example.exe' DownloadUrl='example.com'>", |
| 22 | " <RemotePayload", |
| 23 | " Description='Microsoft ASP.NET Core 3.1.8 - Shared Framework'", |
| 24 | " Hash='61DC9EAA0C8968E48E13C5913ED202A2F8F94DBA'", |
| 25 | " CertificatePublicKey='3756E9BBF4461DCD0AA68E0D1FCFFA9CEA47AC18'", |
| 26 | " CertificateThumbprint='2485A7AFA98E178CB8F30C9838346B514AEA4769'", |
| 27 | " ProductName='Microsoft ASP.NET Core 3.1.8 - Shared Framework'", |
| 28 | " Size='7841880'", |
| 29 | " Version='3.1.8.20421' />", |
| 30 | " </ExePackage>", |
| 31 | " </PackageGroup>", |
| 32 | " </Fragment>", |
| 33 | "</Wix>"); |
| 34 | |
| 35 | var expected = new[] |
| 36 | { |
| 37 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
| 38 | " <Fragment>", |
| 39 | " <PackageGroup Id=\"exe\">", |
| 40 | " <ExePackage>", |
| 41 | " <ExePackagePayload Description=\"Microsoft ASP.NET Core 3.1.8 - Shared Framework\" Hash=\"61DC9EAA0C8968E48E13C5913ED202A2F8F94DBA\" CertificatePublicKey=\"3756E9BBF4461DCD0AA68E0D1FCFFA9CEA47AC18\" CertificateThumbprint=\"2485A7AFA98E178CB8F30C9838346B514AEA4769\" ProductName=\"Microsoft ASP.NET Core 3.1.8 - Shared Framework\" Size=\"7841880\" Version=\"3.1.8.20421\" Name=\"example.exe\" DownloadUrl=\"example.com\" />", |
| 42 | " </ExePackage>", |
| 43 | " </PackageGroup>", |
| 44 | " </Fragment>", |
| 45 | "</Wix>" |
| 46 | }; |
| 47 | |
| 48 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
| 49 | |
| 50 | var messaging = new MockMessaging(); |
| 51 | var converter = new WixConverter(messaging, 2, null, null); |
| 52 | |
| 53 | var errors = converter.ConvertDocument(document); |
| 54 | Assert.Equal(4, errors); |
| 55 | |
| 56 | var actualLines = UnformattedDocumentLines(document); |
| 57 | WixAssert.CompareLineByLine(expected, actualLines); |
| 58 | } |
| 59 | |
| 60 | [Fact] |
| 61 | public void CanConvertMsuPackageRemotePayload() |
| 62 | { |
| 63 | var parse = String.Join(Environment.NewLine, |
| 64 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", |
| 65 | " <Fragment>", |
| 66 | " <PackageGroup Id='msu'>", |
| 67 | " <MsuPackage Name='example.msu' DownloadUrl='example.com' Compressed='no'>", |
| 68 | " <RemotePayload", |
| 69 | " Description='msu description'", |
| 70 | " Hash='71DC9EAA0C8968E48E13C5913ED202A2F8F94DBB'", |
| 71 | " ProductName='msu product name'", |
| 72 | " Size='500'", |
| 73 | " Version='0.0.0.0' />", |
| 74 | " </MsuPackage>", |
| 75 | " </PackageGroup>", |
| 76 | " </Fragment>", |
| 77 | "</Wix>"); |
| 78 | |
| 79 | var expected = new[] |
| 80 | { |
| 81 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
| 82 | " <Fragment>", |
| 83 | " <PackageGroup Id=\"msu\">", |
| 84 | " <MsuPackage>", |
| 85 | " <MsuPackagePayload Description=\"msu description\" Hash=\"71DC9EAA0C8968E48E13C5913ED202A2F8F94DBB\" ProductName=\"msu product name\" Size=\"500\" Version=\"0.0.0.0\" Name=\"example.msu\" DownloadUrl=\"example.com\" />", |
| 86 | " </MsuPackage>", |
| 87 | " </PackageGroup>", |
| 88 | " </Fragment>", |
| 89 | "</Wix>" |
| 90 | }; |
| 91 | |
| 92 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
| 93 | |
| 94 | var messaging = new MockMessaging(); |
| 95 | var converter = new WixConverter(messaging, 2, null, null); |
| 96 | |
| 97 | var errors = converter.ConvertDocument(document); |
| 98 | Assert.Equal(5, errors); |
| 99 | |
| 100 | var actualLines = UnformattedDocumentLines(document); |
| 101 | WixAssert.CompareLineByLine(expected, actualLines); |
| 102 | } |
| 103 | } |
| 104 | } |