Add unit test

This commit is contained in:
sunkaixuan 2022-11-27 16:55:43 +08:00
parent 5d775f27ac
commit 64554180d2

View File

@ -136,11 +136,80 @@ namespace OrmTest
var list4=db.Queryable<SchoolA>()
.LeftJoin<StudentA>((x, y) => (x.SchoolId == y.SchoolId))
.LeftJoin<BookA>((x,y,z)=>y.SchoolId==y.SchoolId)
.Select((x,y,z) => new UnitView01()
.LeftJoin<BookA>((x, y, z,z1) => y.SchoolId == y.SchoolId)
.Select((x,y,z,z1) => new
{
Name=x.SchoolName,
SchoolName= x.SchoolName,
Id="1"
})
.MergeTable()
.Select(it=>new UnitView01() {
Name="a"
},true).ToList();
db.Queryable<SchoolA>()
.LeftJoin<StudentA>((x, y) => (x.SchoolId == y.SchoolId))
.LeftJoin<BookA>((x, y, z) => y.SchoolId == y.SchoolId)
.Select((x,y,z) => new UnitView01()
{
Name = "a"
},true).ToList();
var list6 = db.Queryable<SchoolA>()
.LeftJoin<StudentA>((x, y) => (x.SchoolId == y.SchoolId))
.LeftJoin<BookA>((x, y, z) => y.SchoolId == y.SchoolId)
.Select((x, y, z) => new UnitView01()
{
Name = "a"
}, true).ToSql().Key;
if (list6 != "SELECT @constant0 AS [Name] ,x.[SchoolName] AS [SchoolName] ,y.[StudentId] AS [StudentId] ,z.[BookId] AS [BookId] FROM [SchoolA] x Left JOIN [StudentA] y ON ( [x].[SchoolId] = [y].[SchoolId] ) Left JOIN [BookA] z ON ( [y].[SchoolId] = [y].[SchoolId] ) ")
{
throw new Exception("unit error");
}
db.Queryable<SchoolA>()
.Select(x => new UnitView01()
{
Name = "a"
}, true).ToList();
var list7 = db.Queryable<SchoolA>()
.Select(x => new UnitView01()
{
Name = "a"
}, true).ToSql().Key;
if (list7 != "SELECT @constant0 AS [Name] ,[SchoolName] AS [SchoolName] FROM [SchoolA] ")
{
throw new Exception("unit error");
}
db.Queryable<SchoolA>()
.LeftJoin<StudentA>((x, y) => (x.SchoolId == y.SchoolId))
.Select((x, y) => new UnitView01()
{
Name = "a"
}, true).ToList();
var list8 = db.Queryable<SchoolA>()
.LeftJoin<StudentA>((x, y) => (x.SchoolId == y.SchoolId))
.Select((x, y) => new UnitView01()
{
Name = "a"
}, true).ToSql().Key;
if (list8 != "SELECT @constant0 AS [Name] ,x.[SchoolName] AS [SchoolName] ,y.[StudentId] AS [StudentId] FROM [SchoolA] x Left JOIN [StudentA] y ON ( [x].[SchoolId] = [y].[SchoolId] ) ")
{
throw new Exception("unit error");
}
}
public class UnitView01