Add unit test

This commit is contained in:
sunkaixuan 2022-05-20 19:26:16 +08:00
parent 4389ee561a
commit 2d2a1ac7c1
3 changed files with 40 additions and 1 deletions

View File

@ -85,6 +85,7 @@
<Compile Include="UnitTest\UCodeFirst.cs" />
<Compile Include="UnitTest\UCustom01.cs" />
<Compile Include="UnitTest\UCustom011.cs" />
<Compile Include="UnitTest\UCustom02.cs" />
<Compile Include="UnitTest\UDelete.cs" />
<Compile Include="UnitTest\UJson.cs" />
<Compile Include="UnitTest\Updateable.cs" />

View File

@ -34,7 +34,7 @@ namespace OrmTest
}
public static void Init()
{
UCustom02.Init();
UCustom01.Init();
DeleteTest();
CodeFirst();

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;
using SqlSugar;
namespace OrmTest
{
public class UCustom02
{
public static void Init()
{
var db = NewUnitTest.Db;
//建表
if (!db.DbMaintenance.IsAnyTable("Test001", false))
{
db.CodeFirst.InitTables<UnitTest001>();
}
var dt = DateTime.Now;
db.Aop.OnLogExecuting = (sql, pars) =>
{
var dt1 = pars[0];
};
//用例代码
var result = db.Insertable(new UnitTest001() { id = dt }).ExecuteCommand();//用例代码
var res = db.Queryable<UnitTest001>().WhereClass(new UnitTest001() { id = dt }).ToList();
if (res.Count == 0)
{
throw new Exception("unit error");
}
}
public class UnitTest001
{
[SugarColumn(ColumnDataType = "TIMESTAMP")]
public DateTime id { get; set; }
}
}
}