mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
Add unit test
This commit is contained in:
parent
47753653a4
commit
ea04089c38
@ -100,6 +100,7 @@
|
|||||||
<Compile Include="UnitTest\UInsert3.cs" />
|
<Compile Include="UnitTest\UInsert3.cs" />
|
||||||
<Compile Include="UnitTest\Unitadfa1231.cs" />
|
<Compile Include="UnitTest\Unitadfa1231.cs" />
|
||||||
<Compile Include="UnitTest\UnitFilterasdfas.cs" />
|
<Compile Include="UnitTest\UnitFilterasdfas.cs" />
|
||||||
|
<Compile Include="UnitTest\UnitSqlFunc.cs" />
|
||||||
<Compile Include="UnitTest\UnitSubToList.cs" />
|
<Compile Include="UnitTest\UnitSubToList.cs" />
|
||||||
<Compile Include="UnitTest\Models\EntityBase.cs" />
|
<Compile Include="UnitTest\Models\EntityBase.cs" />
|
||||||
<Compile Include="UnitTest\UnitByteArray.cs" />
|
<Compile Include="UnitTest\UnitByteArray.cs" />
|
||||||
|
@ -124,6 +124,7 @@ namespace OrmTest
|
|||||||
QueryableAsync();
|
QueryableAsync();
|
||||||
AopTest();
|
AopTest();
|
||||||
UTran3.Init();
|
UTran3.Init();
|
||||||
|
UnitSqlFunc.Init();
|
||||||
//Thread();
|
//Thread();
|
||||||
//Thread2();
|
//Thread2();
|
||||||
//Thread3();
|
//Thread3();
|
||||||
|
87
Src/Asp.Net/SqlServerTest/UnitTest/UnitSqlFunc.cs
Normal file
87
Src/Asp.Net/SqlServerTest/UnitTest/UnitSqlFunc.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public class UnitSqlFunc
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var db = NewUnitTest.Db;
|
||||||
|
db.DbMaintenance.TruncateTable<Order>();
|
||||||
|
db.Insertable(new Order() { Name = "a,b,c,aa,bb,cc" }).ExecuteCommand();
|
||||||
|
db.Insertable(new Order() { Name = "e,a,c" }).ExecuteCommand();
|
||||||
|
db.Insertable(new Order() { Name = "zac" }).ExecuteCommand();
|
||||||
|
db.Insertable(new Order() { Name = "ab,az,ad" }).ExecuteCommand();
|
||||||
|
NewMethod(db);
|
||||||
|
NewMethod1(db);
|
||||||
|
NewMethod2(db);
|
||||||
|
NewMethod3(db);
|
||||||
|
NewMethod4(db);
|
||||||
|
NewMethod5(db);
|
||||||
|
NewMethod6(db);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void NewMethod1(SqlSugarClient db)
|
||||||
|
{
|
||||||
|
var count = db.Queryable<Order>().Where(it => SqlFunc.SplitIn(it.Name, "a")).Count();
|
||||||
|
if (count != 2)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void NewMethod(SqlSugarClient db)
|
||||||
|
{
|
||||||
|
var count2 = db.Queryable<Order>().Where(it => SqlFunc.SplitIn(it.Name, "c")).Count();
|
||||||
|
if (count2 != 2)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void NewMethod2(SqlSugarClient db)
|
||||||
|
{
|
||||||
|
var count2 = db.Queryable<Order>().Where(it => SqlFunc.SplitIn(it.Name, "az")).Count();
|
||||||
|
if (count2 != 1)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void NewMethod3(SqlSugarClient db)
|
||||||
|
{
|
||||||
|
var count2 = db.Queryable<Order>().Where(it => SqlFunc.SplitIn(it.Name, "ab")).Count();
|
||||||
|
if (count2 != 1)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void NewMethod4(SqlSugarClient db)
|
||||||
|
{
|
||||||
|
var count2 = db.Queryable<Order>().Where(it => SqlFunc.SplitIn(it.Name, "ad")).Count();
|
||||||
|
if (count2 != 1)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void NewMethod5(SqlSugarClient db)
|
||||||
|
{
|
||||||
|
var count2 = db.Queryable<Order>().Where(it => SqlFunc.SplitIn(it.Name, "z")).Count();
|
||||||
|
if (count2 != 0)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void NewMethod6(SqlSugarClient db)
|
||||||
|
{
|
||||||
|
var count2 = db.Queryable<Order>().Where(it => SqlFunc.SplitIn(it.Name, "zac")).Count();
|
||||||
|
if (count2 != 1)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user