diff --git a/GitHubUpdateNotifier/GitHubUpdateNotifier.cs b/GitHubUpdateNotifier/GitHubUpdateNotifier.cs index b006355..01f8a7d 100644 --- a/GitHubUpdateNotifier/GitHubUpdateNotifier.cs +++ b/GitHubUpdateNotifier/GitHubUpdateNotifier.cs @@ -7,6 +7,11 @@ public sealed class GitHubUpdateNotifier private readonly ReleaseResolver _resolver; public GitHubUpdateNotifier(string owner, string repository, UpdateNotifierOptions options) + : this(owner, repository, options, DefaultProviders()) + { + } + + internal GitHubUpdateNotifier(string owner, string repository, UpdateNotifierOptions options, IReadOnlyList providers) { ArgumentException.ThrowIfNullOrWhiteSpace(owner); ArgumentException.ThrowIfNullOrWhiteSpace(repository); @@ -14,12 +19,11 @@ public sealed class GitHubUpdateNotifier ArgumentNullException.ThrowIfNull(options.CurrentVersion); ArgumentNullException.ThrowIfNull(options.MessageFormatter); ArgumentNullException.ThrowIfNull(options.NotificationHandler); + ArgumentNullException.ThrowIfNull(providers); _repository = new RepositoryReference(owner, repository); _options = options; - _resolver = new ReleaseResolver( - [new ManjuboxReleaseProvider(), new GitHubReleaseProvider()], - Math.Max(0, options.RetryCount)); + _resolver = new ReleaseResolver(providers, Math.Max(0, options.RetryCount)); } public async Task CheckAsync(CancellationToken cancellationToken = default) @@ -53,4 +57,7 @@ public sealed class GitHubUpdateNotifier await _options.NotificationHandler(new UpdateNotification(result.Update!, message), cancellationToken).ConfigureAwait(false); return result; } + + private static IReadOnlyList DefaultProviders() + => [new ManjuboxReleaseProvider(), new GitHubReleaseProvider()]; } diff --git a/GitHubUpdateNotifier/GitHubUpdateNotifier.csproj b/GitHubUpdateNotifier/GitHubUpdateNotifier.csproj index 9e089b0..631e973 100644 --- a/GitHubUpdateNotifier/GitHubUpdateNotifier.csproj +++ b/GitHubUpdateNotifier/GitHubUpdateNotifier.csproj @@ -15,4 +15,10 @@ + + + <_Parameter1>GitHubUpdateNotifier.Tests + + +