Add unit test

This commit is contained in:
sunkaixuan 2023-10-16 12:32:24 +08:00
parent 3b35a6bf7f
commit 3820e0cfb9
2 changed files with 47 additions and 0 deletions

View File

@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
UnitSplitTask.Init();
UnitBulkMerge.Init();
UnitUpdateNavOneToOneFalse.Init();
UnitCreateType.Init();

View File

@ -0,0 +1,46 @@
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();
client.Deleteable(new SpitDemoModel()).SplitTable().ExecuteCommand();
}
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;
}
}