Files
OpenNest/OpenNest.WinForms.Tests/UpdaterServiceTests.cs
T
ajandClaude Opus 5.5 857b88a2c7 fix(update): keep checking after an update is downloaded
The updater stopped checking once a download finished, so a copy left open
overnight restarted into the first build published that evening and then,
a minute after starting, updated again to the newest. Checks now continue:
a newer version replaces the pending download, and if the feed is
unreachable or the newer download fails, the update already on disk stays
ready (read back from Velopack, which may clear older packages on failure).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 07:28:53 -05:00

48 lines
1.9 KiB
C#

namespace OpenNest.WinForms.Tests;
public class UpdaterServiceTests
{
[Fact]
public async Task ManualCheckOutsideAnInstallationReportsNotInstalled()
{
// Test hosts never start through VelopackApp, so there is no locator.
using var updater = new UpdaterService(feedUrl: null, includeDevBuilds: false);
Assert.False(updater.CanUpdate);
Assert.Equal(UpdaterService.CheckResult.NotInstalled, await updater.CheckNowAsync());
Assert.False(updater.HasPendingUpdate);
}
[Theory]
[InlineData("1.3.0-dev.12", null, true)]
[InlineData("1.3.0-dev.12", "1.3.0-dev.9", true)]
[InlineData("1.3.0", "1.3.0-dev.40", true)]
[InlineData("1.3.0-dev.9", "1.3.0-dev.9", false)]
[InlineData("1.3.0-dev.9", "1.3.0-dev.12", false)]
public void ANewerFeedVersionReplacesThePendingDownload(string available, string pending, bool replaces)
{
// A copy left open overnight must restart into the newest build, not the evening's.
var pendingVersion = pending is null ? null : Velopack.SemanticVersion.Parse(pending);
Assert.Equal(replaces,
UpdaterService.IsNewerThanPending(Velopack.SemanticVersion.Parse(available), pendingVersion));
}
[Fact]
public void NoFeedVersionKeepsThePendingDownload()
{
Assert.False(UpdaterService.IsNewerThanPending(null, Velopack.SemanticVersion.Parse("1.3.0-dev.9")));
Assert.False(UpdaterService.IsNewerThanPending(null, null));
}
[Fact]
public void VersionOutsideAnInstallationIsTheAssemblyVersionWithoutBuildMetadata()
{
using var updater = new UpdaterService(feedUrl: null, includeDevBuilds: false);
Assert.Equal(UpdaterService.DisplayVersion(), updater.CurrentVersion);
Assert.DoesNotContain("+", updater.CurrentVersion);
Assert.StartsWith("0.", updater.CurrentVersion);
}
}