mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-04 12:26:52 +00:00
test: Add QQ Music Lyric Downloader UnitTest Method.
This commit is contained in:
@@ -20,11 +20,11 @@ namespace ZonyLrcTools.Tests.Infrastructure.Album
|
||||
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);
|
||||
|
@@ -10,7 +10,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Exceptions
|
||||
public void LoadMessage_Test()
|
||||
{
|
||||
ErrorCodeHelper.LoadErrorMessage();
|
||||
|
||||
|
||||
ErrorCodeHelper.ErrorMessages.ShouldNotBeNull();
|
||||
ErrorCodeHelper.ErrorMessages.Count.ShouldBe(11);
|
||||
}
|
||||
|
@@ -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 QQLyricDownloaderTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public async Task DownloadAsync_Test()
|
||||
{
|
||||
var downloaderList = ServiceProvider.GetRequiredService<IEnumerable<ILyricDownloader>>();
|
||||
var qqDownloader = downloaderList.FirstOrDefault(t => t.DownloaderName == InternalLyricDownloaderNames.QQ);
|
||||
|
||||
qqDownloader.ShouldNotBeNull();
|
||||
var lyric = await qqDownloader.DownloadAsync("Hollow", "Janet Leon");
|
||||
lyric.ShouldNotBeNull();
|
||||
lyric.IsPruneMusic.ShouldBe(false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -40,7 +40,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Network
|
||||
var client = ServiceProvider.GetRequiredService<IWarpHttpClient>();
|
||||
|
||||
var response = await client.GetAsync(@"https://www.baidu.com");
|
||||
|
||||
|
||||
response.ShouldNotBeNull();
|
||||
response.ShouldContain("百度");
|
||||
}
|
||||
|
Reference in New Issue
Block a user