From f53672789d7611d1314085cc9fdfb152bcd57274 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sun, 20 Aug 2023 04:20:49 +0800 Subject: [PATCH] Add init test --- .../SqlSeverTest/UnitTest/EntityInfoTest.cs | 55 +++++++++++++++++++ .../SqlSeverTest/UnitTest/Main.cs | 1 + 2 files changed, 56 insertions(+) create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UnitTest/EntityInfoTest.cs diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/EntityInfoTest.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/EntityInfoTest.cs new file mode 100644 index 000000000..57ddf8c5e --- /dev/null +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/EntityInfoTest.cs @@ -0,0 +1,55 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; +using System.Text; +using System.Xml; + +namespace OrmTest +{ + internal class EntityInfoTest + { + public static void Init() + { + for (int i = 0; i < 100; i++) + { + var db = new SqlSugarClient(new List() + { + //这儿声名所有上下文都生效 + new ConnectionConfig(){ConfigId="0", + ConfigureExternalServices=new ConfigureExternalServices(){ + EntityService=(x,y)=>{ y.IsPrimarykey=true; } + }, + DbType=DbType.SqlServer,ConnectionString=Config.ConnectionString,IsAutoCloseConnection=true}, + new ConnectionConfig(){ConfigId="1", + ConfigureExternalServices=new ConfigureExternalServices(){ + EntityService=(x,y)=>{ y.IsIdentity=true; } + },DbType=DbType.SqlServer,ConnectionString=Config.ConnectionString,IsAutoCloseConnection=true } + }); + + if (db.GetConnection("0").EntityMaintenance.GetEntityInfo().Columns.First().IsIdentity != false + || db.GetConnection("0").EntityMaintenance.GetEntityInfo().Columns.First().IsPrimarykey != true) + { + throw new Exception("unit error"); + } + + if (db.GetConnection("1").EntityMaintenance.GetEntityInfo().Columns.First().IsIdentity != true + || db.GetConnection("1").EntityMaintenance.GetEntityInfo().Columns.First().IsPrimarykey != false) + { + throw new Exception("unit error"); + } + + if (db.EntityMaintenance.GetEntityInfo().Columns.First().IsIdentity != false + || db.EntityMaintenance.GetEntityInfo().Columns.First().IsPrimarykey != true) + { + throw new Exception("unit error"); + } + } + } + } + public class classTest + { + public string Id { get; set; } + } +} diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs index 66d21fbac..231fe1d39 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + EntityInfoTest.Init(); UnitOneToManyafdaa.Init(); Unitadfafa.Init(); AnimalTest.Init();