Fix InvalidOperationException when there are no full remote releases

This commit is contained in:
Stefan Paul Noack
2024-03-12 13:14:53 +02:00
committed by Caelan Sayler
parent 685b4b6744
commit d03caa0cc2
2 changed files with 13 additions and 1 deletions

View File

@@ -105,7 +105,7 @@ namespace Velopack
var result = new List<TSource>(); var result = new List<TSource>();
using (var e = source.GetEnumerator()) { using (var e = source.GetEnumerator()) {
if (!e.MoveNext()) throw new InvalidOperationException("Source sequence doesn't contain any elements."); if (!e.MoveNext()) return result;
var current = e.Current; var current = e.Current;
var resKey = keySelector(current); var resKey = keySelector(current);

View File

@@ -294,6 +294,18 @@ public class UpdateManagerTests
Assert.Throws<ArgumentException>(() => um.CheckForUpdates()); Assert.Throws<ArgumentException>(() => um.CheckForUpdates());
} }
[Fact]
public void CheckFromEmptyFileSource()
{
using var logger = _output.BuildLoggerFor<UpdateManagerTests>();
using var _1 = Utility.GetTempDirectory(out var tempPath);
var source = new SimpleFileSource(new DirectoryInfo(tempPath));
var locator = new TestVelopackLocator("MyCoolApp", "1.0.0", tempPath, logger);
var um = new UpdateManager(source, null, logger, locator);
var info = um.CheckForUpdates();
Assert.Null(info);
}
[Fact] [Fact]
public void NoUpdatesIfCurrentEqualsRemoteVersion() public void NoUpdatesIfCurrentEqualsRemoteVersion()
{ {