diff options
Diffstat (limited to 'src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs')
-rw-r--r-- | src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index 4b9aecd7..3be8af0e 100644 --- a/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs | |||
@@ -1,7 +1,12 @@ | |||
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. | 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 | 2 | ||
3 | using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
4 | |||
5 | [assembly: Parallelize(Scope = ExecutionScope.MethodLevel)] | ||
6 | |||
3 | namespace WixToolsetTest.Firewall | 7 | namespace WixToolsetTest.Firewall |
4 | { | 8 | { |
9 | using System; | ||
5 | using System.Data; | 10 | using System.Data; |
6 | using System.IO; | 11 | using System.IO; |
7 | using System.Linq; | 12 | using System.Linq; |
@@ -621,6 +626,39 @@ namespace WixToolsetTest.Firewall | |||
621 | }, locals.ToArray()); | 626 | }, locals.ToArray()); |
622 | } | 627 | } |
623 | 628 | ||
629 | [TestMethod] | ||
630 | public void CanDecompileWix4FirewallPackage() | ||
631 | { | ||
632 | var folder = TestData.Get(@"TestData\DecompileWix4Firewall"); | ||
633 | var output = Path.Combine(folder, "DecompiledWix4Firewall.xml"); | ||
634 | |||
635 | var result = WixRunner.Execute( | ||
636 | "msi", | ||
637 | "decompile", | ||
638 | "-ext", Path.GetFullPath(typeof(FirewallExtensionFactory).Assembly.Location), | ||
639 | Path.Combine(folder, "Firewall4.msi"), | ||
640 | "-o", output | ||
641 | ); | ||
642 | result.AssertSuccess(); | ||
643 | |||
644 | var doc = XDocument.Load(output); | ||
645 | var actual = doc.Descendants() | ||
646 | .Where(e => e.Name.Namespace == "http://wixtoolset.org/schemas/v4/wxs/firewall") | ||
647 | .Select(fe => new { Name = fe.Name.LocalName, Attributes = fe.Attributes().Select(a => $"{a.Name.LocalName}={a.Value}").ToArray() }) | ||
648 | .ToArray(); | ||
649 | |||
650 | WixAssert.CompareLineByLine(new[] | ||
651 | { | ||
652 | "FirewallException", | ||
653 | "RemoteAddress", | ||
654 | "RemoteAddress", | ||
655 | "RemoteAddress", | ||
656 | "RemoteAddress", | ||
657 | "RemoteAddress", | ||
658 | "FirewallException", | ||
659 | }, actual.Select(a => a.Name).ToArray()); | ||
660 | } | ||
661 | |||
624 | private static void Build(string[] args) | 662 | private static void Build(string[] args) |
625 | { | 663 | { |
626 | var result = WixRunner.Execute(args); | 664 | var result = WixRunner.Execute(args); |
@@ -654,8 +692,9 @@ namespace WixToolsetTest.Firewall | |||
654 | var folder = TestData.Get(@"TestData", path); | 692 | var folder = TestData.Get(@"TestData", path); |
655 | var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); | 693 | var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); |
656 | var output = Path.Combine(folder, $"Firewall{ruleName}.xml"); | 694 | var output = Path.Combine(folder, $"Firewall{ruleName}.xml"); |
695 | var isOfficialBuild = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("WixOfficialBuild")); | ||
657 | 696 | ||
658 | build.BuildAndDecompileAndBuild(Build, Decompile, output, validate: true); | 697 | build.BuildAndDecompileAndBuild(Build, Decompile, output, validate: isOfficialBuild); |
659 | 698 | ||
660 | var doc = XDocument.Load(output); | 699 | var doc = XDocument.Load(output); |
661 | var actual = doc.Descendants() | 700 | var actual = doc.Descendants() |