部分文件夹相关测试

This commit is contained in:
龙腾猫跃 committed 2026-05-12 18:59:03 +08:00
1 parent b821973e2a
commit 5edff6c73f
3 files changed
+48 -143

No files matched your search

+18 -2
View File
@@ -1,17 +1,33 @@
namespace MeloongCore.Tests;
/// <summary>
/// 所有测试的基类。
/// 会初始化 MeloongCore 并重定向日志输出。
/// </summary>
public abstract class TestBase {
public TestBase() {
MeloongCore.Main.Init(new TestLogger());
}
private class TestLogger : BaseLogger {
public override void HandleBehavior(string? rawMessage, string formattedMessage, LogBehavior behavior, Exception? ex)
=> TestContext.Current!.OutputWriter.WriteLine(formattedMessage);
}
}
/// <summary>
/// 用于带文件测试的基类。
/// 会在极端路径下创建测试用的临时文件夹。
/// </summary>
public abstract class TestWithFolder {
public abstract class TestWithFolder : TestBase {
/// <summary>
/// 测试用的临时文件夹路径。
/// 这是一个包含特殊字符的长路径,不以 \\?\ 开头,以 \ 结尾。
/// </summary>
public readonly string tempFolder;
public TestWithFolder() {
public TestWithFolder() : base() {
tempFolder = Path.Combine(
Path.GetTempPath(), "PCL", "Tests",
$"{GetType().Name}-{Guid.NewGuid()}",