mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-04 12:26:52 +00:00
feat: Reinitialize the Repository.
重新初始化仓库。
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Album;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Album
|
||||
{
|
||||
public class NetEaseAlbumDownloaderTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task DownloadDataAsync_Test()
|
||||
{
|
||||
var downloader = ServiceProvider.GetRequiredService<IEnumerable<IAlbumDownloader>>()
|
||||
.FirstOrDefault(x => x.DownloaderName == InternalAlbumDownloaderNames.NetEase);
|
||||
|
||||
downloader.ShouldNotBeNull();
|
||||
var albumBytes = await downloader.DownloadAsync("东方红", null);
|
||||
albumBytes.Length.ShouldBeGreaterThan(0);
|
||||
|
||||
// 显示具体的图像。
|
||||
var tempAlbumPath = Path.Combine(Directory.GetCurrentDirectory(), "tempAlbum.png");
|
||||
File.Delete(tempAlbumPath);
|
||||
|
||||
await using var file = File.Create(tempAlbumPath);
|
||||
await using var ws = new BinaryWriter(file);
|
||||
ws.Write(albumBytes);
|
||||
ws.Flush();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Exceptions;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Exceptions
|
||||
{
|
||||
public class ErrorCodeHelperTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void LoadMessage_Test()
|
||||
{
|
||||
ErrorCodeHelper.LoadErrorMessage();
|
||||
|
||||
ErrorCodeHelper.ErrorMessages.ShouldNotBeNull();
|
||||
ErrorCodeHelper.ErrorMessages.Count.ShouldBe(11);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMessage_Test()
|
||||
{
|
||||
ErrorCodeHelper.LoadErrorMessage();
|
||||
|
||||
ErrorCodeHelper.GetMessage(ErrorCodes.DirectoryNotExist).ShouldBe("需要扫描的目录不存在,请确认路径是否正确。");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Lyric;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Lyric
|
||||
{
|
||||
public class NetEaseLyricDownloaderTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task DownloadAsync_Test()
|
||||
{
|
||||
var downloaderList = ServiceProvider.GetRequiredService<IEnumerable<ILyricDownloader>>();
|
||||
var netEaseDownloader = downloaderList.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.NetEase);
|
||||
|
||||
netEaseDownloader.ShouldNotBeNull();
|
||||
var lyric = await netEaseDownloader.DownloadAsync("Hollow", "Janet Leon");
|
||||
lyric.ShouldNotBeNull();
|
||||
lyric.IsPruneMusic.ShouldBe(false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Config;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Network;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Network
|
||||
{
|
||||
public class WarpClientTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task PostAsync_Test()
|
||||
{
|
||||
var client = ServiceProvider.GetRequiredService<IWarpHttpClient>();
|
||||
|
||||
var response = await client.PostAsync(@"https://www.baidu.com");
|
||||
response.ShouldNotBeNull();
|
||||
response.ShouldContain("百度");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAsync_Test()
|
||||
{
|
||||
var client = ServiceProvider.GetRequiredService<IWarpHttpClient>();
|
||||
|
||||
var response = await client.GetAsync(@"https://www.baidu.com");
|
||||
response.ShouldNotBeNull();
|
||||
response.ShouldContain("百度");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAsyncWithProxy_Test()
|
||||
{
|
||||
var option = ServiceProvider.GetRequiredService<IOptions<ToolOptions>>();
|
||||
option.Value.NetworkOptions.ProxyIp = "127.0.0.1";
|
||||
option.Value.NetworkOptions.ProxyPort = 4780;
|
||||
|
||||
var client = ServiceProvider.GetRequiredService<IWarpHttpClient>();
|
||||
|
||||
var response = await client.GetAsync(@"https://www.baidu.com");
|
||||
|
||||
response.ShouldNotBeNull();
|
||||
response.ShouldContain("百度");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Tag;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Tag
|
||||
{
|
||||
public class FileNameTagInfoProviderTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task LoadAsync_Test()
|
||||
{
|
||||
var provider = ServiceProvider.GetRequiredService<IEnumerable<ITagInfoProvider>>()
|
||||
.FirstOrDefault(p => p.Name == FileNameTagInfoProvider.ConstantName);
|
||||
|
||||
provider.ShouldNotBeNull();
|
||||
|
||||
var info = await provider.LoadAsync(Path.Combine(Directory.GetCurrentDirectory(), "MusicFiles", "曾经艺也 - 荀彧(纯音乐版).mp3"));
|
||||
info.ShouldNotBeNull();
|
||||
info.Name.ShouldBe("荀彧(纯音乐版)");
|
||||
info.Artist.ShouldBe("曾经艺也");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Tag;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Tag
|
||||
{
|
||||
public class TagLoaderTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task LoadTagAsync_Test()
|
||||
{
|
||||
var tagLoader = ServiceProvider.GetRequiredService<ITagLoader>();
|
||||
|
||||
tagLoader.ShouldNotBeNull();
|
||||
var info = await tagLoader.LoadTagAsync(Path.Combine(Directory.GetCurrentDirectory(), "MusicFiles", "曾经艺也 - 荀彧(纯音乐版).mp3"));
|
||||
info.ShouldNotBeNull();
|
||||
info.Name.ShouldBe("荀彧(纯音乐版)");
|
||||
info.Artist.ShouldBe("曾经艺也");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZonyLrcTools.Cli.Infrastructure.Tag;
|
||||
|
||||
namespace ZonyLrcTools.Tests.Infrastructure.Tag
|
||||
{
|
||||
public class TaglibTagInfoProviderTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task LoadAsync_Test()
|
||||
{
|
||||
var provider = ServiceProvider.GetRequiredService<IEnumerable<ITagInfoProvider>>()
|
||||
.FirstOrDefault(p => p.Name == TaglibTagInfoProvider.ConstantName);
|
||||
|
||||
provider.ShouldNotBeNull();
|
||||
|
||||
var info = await provider.LoadAsync(Path.Combine(Directory.GetCurrentDirectory(), "MusicFiles", "曾经艺也 - 荀彧(纯音乐版).mp3"));
|
||||
info.ShouldNotBeNull();
|
||||
info.Name.ShouldBe("荀彧(纯音乐版)");
|
||||
info.Artist.ShouldBe("曾经艺也");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user