mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-07-01 12:11:13 +00:00
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
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();
|
|
}
|
|
}
|
|
} |