Add unit test

This commit is contained in:
sunkaixuna
2022-01-18 11:48:07 +08:00
parent 61862fcde1
commit b223d949f1
3 changed files with 47 additions and 0 deletions

View File

@@ -86,6 +86,7 @@
<Compile Include="Models\ViewOrder.cs" />
<Compile Include="Demo\DemoJ_Report.cs" />
<Compile Include="UnitTest\UBulkCopy.cs" />
<Compile Include="UnitTest\UCustom06.cs" />
<Compile Include="UnitTest\UInsert.cs" />
<Compile Include="UnitTest\UnitCustom01.cs" />
<Compile Include="UnitTest\UQueue.cs" />

View File

@@ -32,6 +32,7 @@ namespace OrmTest
public static void Init()
{
UnitCustom01.Init();
UCustom06.Init();
Bulk();
Insert();
Queue();

View File

@@ -0,0 +1,45 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class UCustom06
{
public static void Init()
{
var db = NewUnitTest.Db;
db.CodeFirst.InitTables<Unit06>();
db.Insertable(new Unit06() { Company = "1", Name = "2", Work = "3" }).ExecuteCommand();
var list = db.Queryable<Unit06>().Select(a => new UnitPeople
{
Name = a.Name,
Job = new UnitJobClass { Company = a.Company, Work = a.Work }
}
).ToList();
Check.Exception(list.First().Job.Company != "1", "unit error");
}
public class Unit06
{
public string Name { get; set; }
public string Company { get; set; }
public string Work { get; set; }
}
public class UnitPeople
{
public string Name { get; set; }
public UnitJobClass Job { get; set; }
}
public class UnitJobClass
{
public string Company { get; set; }
public string Work { get; set; }
}
}
}