Add unit test

This commit is contained in:
sunkaixuan 2022-08-05 19:10:33 +08:00
parent e49996a392
commit a3614073a2
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\UnitStorageableBool.cs" />
<Compile Include="UnitTest\UCustom03.cs" />
<Compile Include="UnitTest\Main.cs" />
<Compile Include="UnitTest\UAdo.cs" />

View File

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

View File

@ -0,0 +1,41 @@
using System;
using SqlSugar;
namespace OrmTest
{
public class UnitStorageableBool
{
public static void Init()
{
var db = NewUnitTest.Db;
//建表
if (!db.DbMaintenance.IsAnyTable("Test0011", false))
{
db.CodeFirst.InitTables<Test001>();
}
db.Aop.OnError = (exp) =>//SQL报错
{
//Console.WriteLine($"SqlSugar[Error]{UtilMethods.GetSqlString(DbType.SqlServer, exp.Sql, exp.Parametres)}" + Environment.NewLine);
};
//用例代码
var result = db.Insertable(new Test001() { id = true }).ExecuteCommand();//用例代码
var result1 = db.Insertable(new Test001() { id = false }).ExecuteCommand();//用例代码
var res = db.Storageable(new Test001() { id1 = false, id = false }).WhereColumns(x => x.id1)
.SplitUpdate(x => x.Any()).ToStorage();
res.AsUpdateable.ExecuteCommand();
//Console.WriteLine(result);
//Console.WriteLine("用例跑完");
// Console.ReadKey();
}
//建类
[SugarTable("Test0011")]
public class Test001
{
[SugarColumn(ColumnDataType = "NUMBER(1)", SqlParameterDbType = System.Data.DbType.Int16)]
public bool id { get; set; }
[SugarColumn(ColumnDataType = "NUMBER(1)", SqlParameterDbType = System.Data.DbType.Int16)]
public bool id1 { get; set; }
}
}
}