Add unit test

This commit is contained in:
sunkaixuan 2023-10-16 13:22:18 +08:00
parent 1b9507247a
commit 1ce7a4ce5b
2 changed files with 48 additions and 0 deletions

View File

@ -30,6 +30,7 @@ namespace OrmTest
}
public static void Init()
{
UnitSplitTask.Init();
UinitUpdateNavOneToOne.Init();
UnitCreateNavClass.Init();
UnitBulkMerge.Init();

View File

@ -0,0 +1,47 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
internal class UnitSplitTask
{
public static void Init()
{
var client = NewUnitTest.Db;
Console.WriteLine("Hello, World!");
List<Task> tasks = new List<Task>()
{
CreateTask(client.CopyNew()),
CreateTask(client.CopyNew()),
CreateTask(client.CopyNew())
};
Task.WhenAll(tasks).GetAwaiter().GetResult();
var table = client.SplitHelper<SpitDemoModel>().GetTableName(SplitType.Day);
client.DbMaintenance.DropTable(table);
}
private static Task CreateTask(ISqlSugarClient client)
{
return Task.Run(() => {
client.Insertable(new SpitDemoModel()).SplitTable().ExecuteCommand();
});
}
}
[SplitTable(SplitType.Day)]
[SugarTable("SpitDemo_{year}{month}{day}")]
public class SpitDemoModel
{
[SugarColumn(IsPrimaryKey = true)]
public Guid Id { get; set; } = Guid.NewGuid();
[SplitField]
public DateTime CreateTime { get; set; } = DateTime.Now;
}
}