mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 02:14:53 +08:00
Update unit test
This commit is contained in:
@@ -41,6 +41,20 @@ namespace OrmTest
|
|||||||
sno = "a",
|
sno = "a",
|
||||||
username = "admin"
|
username = "admin"
|
||||||
}).ExecuteCommand();
|
}).ExecuteCommand();
|
||||||
|
db.Insertable(new OperatorInfo()
|
||||||
|
{
|
||||||
|
id = "3",
|
||||||
|
createTime = DateTime.Now,
|
||||||
|
isDel = 1,
|
||||||
|
isDisabled = 1,
|
||||||
|
openid = "",
|
||||||
|
phone = "",
|
||||||
|
pwd = "",
|
||||||
|
realname = "a01",
|
||||||
|
remark = "a",
|
||||||
|
sno = "a",
|
||||||
|
username = "admin"
|
||||||
|
}).ExecuteCommand();
|
||||||
var id=db.Insertable(new Role()
|
var id=db.Insertable(new Role()
|
||||||
{
|
{
|
||||||
id=1,
|
id=1,
|
||||||
@@ -60,10 +74,19 @@ namespace OrmTest
|
|||||||
db.Queryable<OperatorInfo>()
|
db.Queryable<OperatorInfo>()
|
||||||
.Includes(x => x.Roles).Where(x => x.Roles.Any(z=>z.id==1))
|
.Includes(x => x.Roles).Where(x => x.Roles.Any(z=>z.id==1))
|
||||||
.ToList();
|
.ToList();
|
||||||
var list=db.Queryable<OperatorInfo>()
|
var list = db.Queryable<OperatorInfo>()
|
||||||
.Includes(x => x.Roles).Where(x => x.Roles.Any())
|
.Includes(x => x.Roles).Where(x=>x.Roles.Any()).ToList();
|
||||||
.ToListAsync().GetAwaiter().GetResult();
|
if (list.Count != 2)
|
||||||
var list2=db.Queryable<OperatorInfo>()
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
var list3 = db.Queryable<OperatorInfo>()
|
||||||
|
.Includes(x => x.Roles).Where(x => x.Roles.Count()==0).ToList();
|
||||||
|
if (list3.Count != 1)
|
||||||
|
{
|
||||||
|
throw new Exception("unit error");
|
||||||
|
}
|
||||||
|
var list2=db.Queryable<OperatorInfo>()
|
||||||
.Includes(x => x.Roles.MappingField(z=>z.name,()=>x.username).ToList())
|
.Includes(x => x.Roles.MappingField(z=>z.name,()=>x.username).ToList())
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user