namespace ServerTest;
using Common;
using Newtonsoft.Json;
using System.Text.Json.Nodes;
using Xunit;
///
/// xUnit将会对每个测试方法创建一个测试上下文,IClassFixture可以用来创建类中共享测试上下文,
///
/// XUnit 的测试方法不是按照顺序执行,所以注意对象状态
///
public class DirFileOpTest(FilesSeed filesSeed) : IClassFixture
{
private readonly FilesSeed filesSeed = filesSeed;
///
/// 测试文件目录写入和提取
///
[Fact]
public void FileDirWriteExtract()
{
var (IsSuccess, Message) = filesSeed.NewDir.WriteByThisInfo();
Assert.True(IsSuccess);
Dir nd = new(filesSeed.NewDir.FormatedPath);
nd.ExtractInfo();
Assert.True(nd.IsEqual(filesSeed.NewDir));
}
///
/// 测试文件差异比较
///
[Fact]
public void FileDirDiff()
{
var cDDir = filesSeed.NewDir.Diff(filesSeed.OldDir);
// Console.WriteLine("################################");
// Console.WriteLine(cDDir.Children.Count);
//Assert.True(IsSuccess);
var str = JsonConvert.SerializeObject(cDDir);
Assert.True(cDDir.Children.Count !=0);
Assert.True(filesSeed.DiffDir.IsEqual(cDDir));
}
///
/// 测试文件合并
///
[Fact]
public void DirsCombine()
{
var OldDirClone = filesSeed.OldDir.Clone();
var (IsSuccess, Message) = OldDirClone.Combine(filesSeed.DiffDir);
Assert.True(IsSuccess);
//Assert.False(filesSeed.NewDir.IsEqual(filesSeed.OldDir));
OldDirClone.ResetRootPath("OldDir","NewDir");
// Console.WriteLine(filesSeed.OldDir.Path);
Assert.True(OldDirClone.IsEqual(filesSeed.NewDir));
}
///
/// 测试同步是否成功
///
[Fact]
public void FinalSyncFileDir()
{
Assert.True(true);
}
}