2024-06-24 09:27:12 +00:00
|
|
|
using Common;
|
2024-07-30 07:36:42 +00:00
|
|
|
using Xunit;
|
|
|
|
|
2024-07-12 06:15:38 +00:00
|
|
|
/*using Newtonsoft.Json;*/
|
|
|
|
|
|
|
|
namespace ServerTest;
|
|
|
|
|
2024-07-30 07:36:42 +00:00
|
|
|
public class DirFileOpTest : IDisposable
|
2024-06-24 09:27:12 +00:00
|
|
|
{
|
2024-07-30 07:36:42 +00:00
|
|
|
private readonly FilesSeed filesSeed = new();
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
//filesSeed.Dispose();
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
2024-06-24 09:27:12 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 测试文件目录写入和提取
|
|
|
|
/// </summary>
|
2024-07-30 07:36:42 +00:00
|
|
|
[Fact]
|
2024-06-24 09:27:12 +00:00
|
|
|
public void FileDirWriteExtract()
|
|
|
|
{
|
2024-07-26 04:49:08 +00:00
|
|
|
filesSeed.NewDir.WriteByThisInfo(filesSeed.fileDirOp);
|
|
|
|
filesSeed.OldDir.WriteByThisInfo(filesSeed.fileDirOp);
|
2024-07-12 06:15:38 +00:00
|
|
|
Dir nnd = new(filesSeed.NewDir.FormatedPath);
|
|
|
|
nnd.ExtractInfo();
|
|
|
|
Assert.True(nnd.IsEqual(filesSeed.NewDir), "新文件提取文件夹的信息与写入信息不一致!");
|
|
|
|
Dir nod = new(filesSeed.OldDir.FormatedPath);
|
|
|
|
nod.ExtractInfo();
|
|
|
|
Assert.True(nod.IsEqual(filesSeed.OldDir), "旧提取文件夹的信息与写入信息不一致!");
|
2024-06-24 09:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 测试文件差异比较
|
|
|
|
/// </summary>
|
2024-07-30 07:36:42 +00:00
|
|
|
[Fact]
|
2024-06-24 09:27:12 +00:00
|
|
|
public void FileDirDiff()
|
|
|
|
{
|
|
|
|
var cDDir = filesSeed.NewDir.Diff(filesSeed.OldDir);
|
|
|
|
// Console.WriteLine("################################");
|
|
|
|
// Console.WriteLine(cDDir.Children.Count);
|
|
|
|
//Assert.True(IsSuccess);
|
|
|
|
|
2024-07-12 06:15:38 +00:00
|
|
|
/*var str = JsonConvert.SerializeObject(cDDir);*/
|
|
|
|
Assert.True(filesSeed.DiffDir.IsEqual(cDDir), "文件对比结果错误!");
|
2024-06-24 09:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2024-07-12 06:15:38 +00:00
|
|
|
/// 测试同步是否成功
|
2024-06-24 09:27:12 +00:00
|
|
|
/// </summary>
|
2024-07-30 07:36:42 +00:00
|
|
|
[Fact]
|
2024-07-12 06:15:38 +00:00
|
|
|
public void SyncFileDir()
|
2024-06-24 09:27:12 +00:00
|
|
|
{
|
2024-07-30 07:36:42 +00:00
|
|
|
filesSeed.OldDir.WriteByThisInfo(filesSeed.fileDirOp);
|
2024-07-30 05:24:47 +00:00
|
|
|
filesSeed.OldDir.CombineJustDirFile(filesSeed.fileDirOp, filesSeed.DiffDir);
|
2024-07-12 06:15:38 +00:00
|
|
|
Dir oldSync = new(filesSeed.OldDir.FormatedPath);
|
|
|
|
oldSync.ExtractInfo();
|
|
|
|
oldSync.ResetRootPath(filesSeed.OldDir.FormatedPath, filesSeed.NewDir.FormatedPath);
|
|
|
|
Assert.True(oldSync.IsEqual(filesSeed.NewDir), "文件夹同步后信息保持不一致!");
|
2024-06-24 09:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2024-07-12 06:15:38 +00:00
|
|
|
/// 测试文件合并
|
2024-06-24 09:27:12 +00:00
|
|
|
/// </summary>
|
2024-07-30 07:36:42 +00:00
|
|
|
[Fact]
|
2024-07-12 06:15:38 +00:00
|
|
|
public void DirsCombine()
|
2024-06-24 09:27:12 +00:00
|
|
|
{
|
2024-07-26 04:49:08 +00:00
|
|
|
filesSeed.OldDir.CombineJustObject(filesSeed.DiffDir);
|
2024-07-12 06:15:38 +00:00
|
|
|
//Assert.False(filesSeed.NewDir.IsEqual(filesSeed.OldDir));
|
|
|
|
filesSeed.OldDir.ResetRootPath("OldDir", "NewDir");
|
|
|
|
// Console.WriteLine(filesSeed.OldDir.Path);
|
|
|
|
Assert.True(filesSeed.OldDir.IsEqual(filesSeed.NewDir), "合并结果不一致!");
|
|
|
|
}
|
2024-07-30 07:36:42 +00:00
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void Tt()
|
|
|
|
{
|
|
|
|
filesSeed.NewDir.WriteByThisInfo(filesSeed.fileDirOp);
|
|
|
|
var c = new FileDirOpForPack(filesSeed.NewDir.FormatedPath, filesSeed.TestPath + "/");
|
|
|
|
c.FinallyCompress();
|
|
|
|
|
|
|
|
var d = new FileDirOpForUnpack(
|
|
|
|
filesSeed.TestPath + "/",
|
|
|
|
filesSeed.TestPath + "/",
|
|
|
|
c.SyncId
|
|
|
|
);
|
|
|
|
d.FirstUnComparess();
|
|
|
|
}
|
2024-06-24 09:27:12 +00:00
|
|
|
}
|