|
| 1 | +using System.Xml.Linq; |
| 2 | + |
| 3 | +namespace ResoDrive.App.Tests; |
| 4 | + |
| 5 | +public sealed class InstallerPackageTests |
| 6 | +{ |
| 7 | + private static readonly XNamespace Wix = "http://wixtoolset.org/schemas/v4/wxs"; |
| 8 | + |
| 9 | + [Fact] |
| 10 | + public void UpgradePreparationIsBestEffortAndRunsWithoutPowerShell() |
| 11 | + { |
| 12 | + var action = LoadAction("PrepareInstalledResoDriveForUpgrade"); |
| 13 | + |
| 14 | + Assert.Equal("ResoDriveExecutableFile", (string?)action.Attribute("FileRef")); |
| 15 | + Assert.Equal("--prepare-update", (string?)action.Attribute("ExeCommand")); |
| 16 | + Assert.Equal("ignore", (string?)action.Attribute("Return")); |
| 17 | + Assert.Equal("yes", (string?)action.Attribute("Impersonate")); |
| 18 | + } |
| 19 | + |
| 20 | + [Fact] |
| 21 | + public void UpgradeStopFallbackIsHiddenPathScopedAndWaitsForExit() |
| 22 | + { |
| 23 | + var action = LoadAction("StopResoDriveForUpgrade"); |
| 24 | + var command = Assert.IsType<XAttribute>(action.Attribute("ExeCommand")).Value; |
| 25 | + |
| 26 | + Assert.Equal("check", (string?)action.Attribute("Return")); |
| 27 | + Assert.Equal("no", (string?)action.Attribute("Impersonate")); |
| 28 | + Assert.Contains("-WindowStyle Hidden", command, StringComparison.Ordinal); |
| 29 | + Assert.Contains("Path -eq $p", command, StringComparison.Ordinal); |
| 30 | + Assert.Contains("WaitForExit()", command, StringComparison.Ordinal); |
| 31 | + Assert.Contains(";exit 0", command, StringComparison.Ordinal); |
| 32 | + } |
| 33 | + |
| 34 | + private static XElement LoadAction(string id) |
| 35 | + { |
| 36 | + var document = XDocument.Load(Path.Combine(AppContext.BaseDirectory, "Fixtures", "Package.wxs")); |
| 37 | + return Assert.Single(document.Descendants(Wix + "CustomAction"), action => |
| 38 | + (string?)action.Attribute("Id") == id); |
| 39 | + } |
| 40 | +} |
0 commit comments