Add unit test

This commit is contained in:
sunkaixuan 2022-06-07 20:23:56 +08:00
parent 971e30ad26
commit c2a2b20b8a
3 changed files with 43 additions and 0 deletions

View File

@ -80,6 +80,7 @@
<Compile Include="Models\ViewOrder.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTest\UCustom03.cs" />
<Compile Include="UnitTest\Main.cs" />
<Compile Include="UnitTest\UAdo.cs" />
<Compile Include="UnitTest\UCodeFirst.cs" />

View File

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

View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
namespace OrmTest
{
public class UCustom03
{
public static void Init()
{
var db = NewUnitTest.Db;
db.Aop.OnLogExecuting = (sql, pars) =>
{
Console.WriteLine($"SqlSugar[Info]{UtilMethods.GetSqlString(DbType.SqlServer, sql, pars) }");
};
//建表
if (!db.DbMaintenance.IsAnyTable("Test0011", false))
{
db.CodeFirst.InitTables<Test001111>();
}
//用例代码
var dt = DateTime.Now.Date;
var result = db.Insertable(new Test001111() { id = dt }).ExecuteCommand();//用例代码
var res = db.Queryable<Test001111>().WhereClass(new Test001111() { id = dt }).ToList();
//Console.WriteLine(result);
Console.WriteLine("用例跑完");
Console.ReadKey();
}
//建类
public class Test001111
{
[SqlSugar.SugarColumn(SqlParameterDbType = System.Data.DbType.Date)]
public DateTime? id { get; set; }
}
}
}