From 634e9e3e0a6730611ff03edcc72ac0052596ef30 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 1 Oct 2022 10:12:59 +0800 Subject: [PATCH] Add unit test --- Src/Asp.Net/MySqlTest/MySqlTest.csproj | 1 + Src/Asp.Net/MySqlTest/UnitTest/Main.cs | 1 + Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs | 46 +++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs diff --git a/Src/Asp.Net/MySqlTest/MySqlTest.csproj b/Src/Asp.Net/MySqlTest/MySqlTest.csproj index 51a080c65..cebdef4b6 100644 --- a/Src/Asp.Net/MySqlTest/MySqlTest.csproj +++ b/Src/Asp.Net/MySqlTest/MySqlTest.csproj @@ -86,6 +86,7 @@ + diff --git a/Src/Asp.Net/MySqlTest/UnitTest/Main.cs b/Src/Asp.Net/MySqlTest/UnitTest/Main.cs index 3d8e52f7d..3bad3cb94 100644 --- a/Src/Asp.Net/MySqlTest/UnitTest/Main.cs +++ b/Src/Asp.Net/MySqlTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + UCustom20.Init(); UCustom07.Init(); UnitTestReturnPkList.Init(); UnitSameKeyBug.Init(); diff --git a/Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs b/Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs new file mode 100644 index 000000000..10ccbca21 --- /dev/null +++ b/Src/Asp.Net/MySqlTest/UnitTest/UCustom20.cs @@ -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(); + db.Insertable(new Order() { Id = 1, Name = "jack", CreateTime = DateTime.Now, CustomId = 1 }).ExecuteCommand(); + + var test8 = db.Queryable() + .LeftJoin((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; } + } + } +}