FileSqlServerSync/Server/ServerTest/DirFileOpTest.cs
zhaoyouya 46315ba760 chore: 添加sqlite 数据库,remote server 增加一些接口
添加了一些数据模型,添加了一些简单的单元测试
2024-10-12 21:57:45 +08:00

72 lines
2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace ServerTest;
using Common;
using Newtonsoft.Json;
using System.Text.Json.Nodes;
using Xunit;
/// <summary>
/// xUnit将会对每个测试方法创建一个测试上下文IClassFixture可以用来创建类中共享测试上下文
///
/// XUnit 的测试方法不是按照顺序执行,所以注意对象状态
/// </summary>
public class DirFileOpTest(FilesSeed filesSeed) : IClassFixture<FilesSeed>
{
private readonly FilesSeed filesSeed = filesSeed;
/// <summary>
/// 测试文件目录写入和提取
/// </summary>
[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));
}
/// <summary>
/// 测试文件差异比较
/// </summary>
[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));
}
/// <summary>
/// 测试文件合并
/// </summary>
[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));
}
/// <summary>
/// 测试同步是否成功
/// </summary>
[Fact]
public void FinalSyncFileDir()
{
Assert.True(true);
}
}