Add unit test

This commit is contained in:
sunkaixuan 2022-08-31 13:22:39 +08:00
parent ea65c545d5
commit 1e1a8e0f14
3 changed files with 40 additions and 0 deletions

View File

@ -97,6 +97,7 @@
<Compile Include="Models\OrderItem.cs" /> <Compile Include="Models\OrderItem.cs" />
<Compile Include="Demo\Demo0_SqlSugarClient.cs" /> <Compile Include="Demo\Demo0_SqlSugarClient.cs" />
<Compile Include="Models\ViewOrder.cs" /> <Compile Include="Models\ViewOrder.cs" />
<Compile Include="UnitTest\UCustom20.cs" />
<Compile Include="UnitTest\UnitUpdateSubQuery.cs" /> <Compile Include="UnitTest\UnitUpdateSubQuery.cs" />
<Compile Include="UnitTest\UnitManyToManyDeleteNav.cs" /> <Compile Include="UnitTest\UnitManyToManyDeleteNav.cs" />
<Compile Include="UnitTest\UnitCustom12312.cs" /> <Compile Include="UnitTest\UnitCustom12312.cs" />

View File

@ -31,6 +31,7 @@ namespace OrmTest
} }
public static void Init() public static void Init()
{ {
UCustom20.Init();
UTran2.Init(); UTran2.Init();
UnitUpdateSubQuery.Init(); UnitUpdateSubQuery.Init();
UnitManyToManyDeleteNav.Init(); UnitManyToManyDeleteNav.Init();

View File

@ -0,0 +1,38 @@
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;
var list = db.Queryable<Order>()
.Take(2)
.Select(i => new TestDTO
{
SubOne = new TestSubDTO { NameOne = i.Name, NameTwo = i.Name },
SubTwo = new TestSubDTO { NameOne = i.Name, NameTwo = i.Name }
})
.ToList();
}
public class TestDTO
{
public TestSubDTO SubOne { get; set; }
public TestSubDTO SubTwo { get; set; }
}
public class TestSubDTO
{
public string NameOne { get; set; }
public string NameTwo { get; set; }
}
}
}