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
9fdf91608a
commit
634e9e3e0a
@ -86,6 +86,7 @@
|
||||
<Compile Include="Models\Unit\Custom1\PurchaseDetailModel.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="Demo\DemoJ_Report.cs" />
|
||||
<Compile Include="UnitTest\UCustom20.cs" />
|
||||
<Compile Include="UnitTest\UBulkCopy2.cs" />
|
||||
<Compile Include="UnitTest\UCustom07.cs" />
|
||||
<Compile Include="UnitTest\UDelete.cs" />
|
||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
UCustom20.Init();
|
||||
UCustom07.Init();
|
||||
UnitTestReturnPkList.Init();
|
||||
UnitSameKeyBug.Init();
|
||||
|
46
Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs
Normal file
46
Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class UCustom20
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var db = NewUnitTest.Db;
|
||||
db.DbMaintenance.TruncateTable<Order>();
|
||||
db.Insertable(new Order() { Id = 1, Name = "jack", CreateTime = DateTime.Now, CustomId = 1 }).ExecuteCommand();
|
||||
|
||||
var test8 = db.Queryable<Order>()
|
||||
.LeftJoin<Order>((x, y) => x.Id == y.Id)
|
||||
.Take(2)
|
||||
.Select((x, y) => new TestDTO
|
||||
{
|
||||
SubOne = new TestSubDTO { NameOne = false, NameTwo = x.Name }
|
||||
})
|
||||
.ToList();
|
||||
|
||||
if (test8.First().SubOne.NameOne != false || test8.First().SubOne.NameTwo != "jack")
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
}
|
||||
|
||||
public class TestDTO
|
||||
{
|
||||
public TestSubDTO SubOne { get; set; }
|
||||
|
||||
public TestSubDTO SubTwo { get; set; }
|
||||
}
|
||||
|
||||
public class TestSubDTO
|
||||
{
|
||||
public bool NameOne { get; set; }
|
||||
|
||||
public string NameTwo { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user