mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-08-31 17:56:53 +00:00
feat: Add auto-detect update feature.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Common.Updater;
|
||||
using ZonyLrcTools.Common.Updater.JsonModel;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Updater;
|
||||
|
||||
public class UpdaterTests : TestBase
|
||||
{
|
||||
private readonly IUpdater _updater;
|
||||
|
||||
public UpdaterTests()
|
||||
{
|
||||
_updater = GetService<IUpdater>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CheckUpdateAsync()
|
||||
{
|
||||
var response = new NewVersionResponse
|
||||
{
|
||||
NewVersion = new Version(0, 0, 1, 49),
|
||||
NewVersionDescription = "这里是新版本描述",
|
||||
UpdateTime = DateTime.Now,
|
||||
Items = new List<NewVersionItem>
|
||||
{
|
||||
new NewVersionItem
|
||||
{
|
||||
ItemType = NewVersionItemType.Important,
|
||||
Url = "https://github.com/real-zony/ZonyLrcToolsX/releases/tag/ZonyLrcToolsX_Alpha.2022092449"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var responseString = JsonConvert.SerializeObject(response);
|
||||
responseString.ShouldNotBeNull();
|
||||
|
||||
await _updater.CheckUpdateAsync();
|
||||
}
|
||||
}
|
@@ -2,6 +2,7 @@ using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ZonyLrcTools.Cli;
|
||||
using ZonyLrcTools.Cli.Commands;
|
||||
using ZonyLrcTools.Common;
|
||||
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
|
||||
|
||||
namespace ZonyLrcTools.Tests
|
||||
@@ -22,6 +23,7 @@ namespace ZonyLrcTools.Tests
|
||||
var service = new ServiceCollection();
|
||||
|
||||
service.BeginAutoDependencyInject<Program>();
|
||||
service.BeginAutoDependencyInject<MusicInfo>();
|
||||
service.ConfigureToolService();
|
||||
service.ConfigureConfiguration();
|
||||
|
||||
|
Reference in New Issue
Block a user