mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Add unit test
This commit is contained in:
parent
ea04089c38
commit
6c4a7cf073
@ -138,6 +138,7 @@
|
||||
<Compile Include="UnitTest\UInsert3.cs" />
|
||||
<Compile Include="UnitTest\UnitCustom01.cs" />
|
||||
<Compile Include="UnitTest\UnitSameKeyBug.cs" />
|
||||
<Compile Include="UnitTest\UnitSqlFunc.cs" />
|
||||
<Compile Include="UnitTest\UnitSubToList.cs" />
|
||||
<Compile Include="UnitTest\UnitSubToList001.cs" />
|
||||
<Compile Include="UnitTest\UnitTestReturnPkList.cs" />
|
||||
|
87
Src/Asp.Net/MySqlTest/UnitTest/UnitSqlFunc.cs
Normal file
87
Src/Asp.Net/MySqlTest/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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -119,6 +119,7 @@
|
||||
<Compile Include="UnitTest\UCustom014.cs" />
|
||||
<Compile Include="UnitTest\UCustom015.cs" />
|
||||
<Compile Include="UnitTest\UCustom016.cs" />
|
||||
<Compile Include="UnitTest\UnitSqlFunc.cs" />
|
||||
<Compile Include="UnitTest\UnitSubToList.cs" />
|
||||
<Compile Include="UnitTest\UnitTestReturnPkList.cs" />
|
||||
<Compile Include="UnitTest\USave.cs" />
|
||||
|
87
Src/Asp.Net/PgSqlTest/UnitTest/UnitSqlFunc.cs
Normal file
87
Src/Asp.Net/PgSqlTest/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