fix: Fixed the path issue #128.

We should avoid using the Directory.GetCurrentDirectory() method, as it
can result in retrieving incorrect paths.
This commit is contained in:
real-zony
2023-03-19 11:28:04 +08:00
parent 286731b1a6
commit 572e555f2a
6 changed files with 9 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -20,7 +21,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Album
albumBytes.Length.ShouldBeGreaterThan(0);
// 显示具体的图像。
var tempAlbumPath = Path.Combine(Directory.GetCurrentDirectory(), "tempAlbum.png");
var tempAlbumPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tempAlbum.png");
File.Delete(tempAlbumPath);
await using var file = File.Create(tempAlbumPath);

View File

@@ -1,9 +1,9 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit;
using ZonyLrcTools.Cli.Infrastructure.Tag;
using ZonyLrcTools.Common.TagInfo;
namespace ZonyLrcTools.Tests.Infrastructure.Tag
@@ -16,7 +16,7 @@ namespace ZonyLrcTools.Tests.Infrastructure.Tag
var tagLoader = ServiceProvider.GetRequiredService<ITagLoader>();
tagLoader.ShouldNotBeNull();
var info = await tagLoader.LoadTagAsync(Path.Combine(Directory.GetCurrentDirectory(), "MusicFiles", "曾经艺也 - 荀彧(纯音乐版).mp3"));
var info = await tagLoader.LoadTagAsync(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MusicFiles", "曾经艺也 - 荀彧(纯音乐版).mp3"));
info.ShouldNotBeNull();
info.Name.ShouldBe("荀彧(纯音乐版)");
info.Artist.ShouldBe("曾经艺也");