From e946bcc1b1389769199ce8d804f219fc612c0c3c Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Mon, 24 Jul 2023 17:40:34 +0800
Subject: [PATCH] Add unit test
---
Src/Asp.Net/SqliteTest/SqliteTest.csproj | 1 +
Src/Asp.Net/SqliteTest/UnitTest/Main.cs | 1 +
.../SqliteTest/UnitTest/Unitadfaafsd.cs | 100 ++++++++++++++++++
3 files changed, 102 insertions(+)
create mode 100644 Src/Asp.Net/SqliteTest/UnitTest/Unitadfaafsd.cs
diff --git a/Src/Asp.Net/SqliteTest/SqliteTest.csproj b/Src/Asp.Net/SqliteTest/SqliteTest.csproj
index 6bb4fe1c8..f0cdd362b 100644
--- a/Src/Asp.Net/SqliteTest/SqliteTest.csproj
+++ b/Src/Asp.Net/SqliteTest/SqliteTest.csproj
@@ -90,6 +90,7 @@
+
diff --git a/Src/Asp.Net/SqliteTest/UnitTest/Main.cs b/Src/Asp.Net/SqliteTest/UnitTest/Main.cs
index a369fa03d..07d821fc5 100644
--- a/Src/Asp.Net/SqliteTest/UnitTest/Main.cs
+++ b/Src/Asp.Net/SqliteTest/UnitTest/Main.cs
@@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
+ Unitadfaafsd.Init();
UFilter2.Init();
UinitCustomConvert.Init();
UnitNavUpdatee12.Init();
diff --git a/Src/Asp.Net/SqliteTest/UnitTest/Unitadfaafsd.cs b/Src/Asp.Net/SqliteTest/UnitTest/Unitadfaafsd.cs
new file mode 100644
index 000000000..f1da50da8
--- /dev/null
+++ b/Src/Asp.Net/SqliteTest/UnitTest/Unitadfaafsd.cs
@@ -0,0 +1,100 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+namespace OrmTest
+{
+ internal class Unitadfaafsd
+ {
+ public static void Init()
+ {
+ SqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = Config.ConnectionString,
+ DbType = DbType.Sqlite,
+ IsAutoCloseConnection = true
+ },
+ db =>
+ {
+ db.Aop.OnLogExecuting = (sql, pars) =>
+ {
+ Console.WriteLine(sql);//输出sql,查看执行sql 性能无影响
+ };
+ });
+ _db.CodeFirst.InitTables();
+ _db.InsertNav(new JqdsrdbEntity()
+ {
+ Jqdsrdbh = "a",
+ Jqdsrgxbs = new List()
+ {
+ new JqdsrgxbEntity(){
+ Jqdsrdbh= "a",
+ Id= 1,
+ Sfmc= "a",
+ Sf="a"
+ }
+ }
+ }).Include(x => x.Jqdsrgxbs).ExecuteCommand();
+ var items = _db.Queryable()
+ .Includes(dsr => dsr.Jqdsrgxbs)
+ .Select((dsr) =>
+ new Resp
+ {
+ Sf = dsr.Jqdsrgxbs.Select(sf => sf.Sfmc),
+ IsShowOperationButton = true
+ },
+ isAutoFill: true)
+ .ToListAsync().GetAwaiter().GetResult();
+ if (items.First().Jqdsrdbh != "a" || items.First().IsShowOperationButton == false ||
+ items.First().Sf.Count() == 0)
+ {
+ throw new Exception("unit error");
+ }
+ }
+ }
+ [SugarTable("jqdsrdb")]
+ public class JqdsrdbEntity
+ {
+
+ [SugarColumn(ColumnName = "jqdsrdbh", IsPrimaryKey = true)]
+ public string Jqdsrdbh { get; set; }
+
+ [Navigate(NavigateType.OneToMany, nameof(JqdsrgxbEntity.Jqdsrdbh))]
+ public List Jqdsrgxbs { get; set; }
+
+ }
+
+ [SugarTable("jqdsrgxb")]
+ public class JqdsrgxbEntity
+ {
+ [SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
+ public long Id { get; set; }
+
+ [SugarColumn(ColumnName = "sf")]
+ public string Sf { get; set; }
+
+ [SugarColumn(ColumnName = "sfmc")]
+ public string Sfmc { get; set; }
+
+ [SugarColumn(ColumnName = "jqdsrdbh")]
+ public string Jqdsrdbh { get; set; }
+
+ }
+
+ public class Resp
+ {
+ public string Jqdsrdbh { get; set; }
+ public bool IsShowOperationButton { get; set; }
+
+ public IEnumerable Sf { get; set; }
+ }
+
+ public class JqdsrgxbModel
+ {
+ public string Sf { get; set; }
+
+ public string Sfmc { get; set; }
+ }
+}