From 131b577b15a557f6b66c38238b34b73d8eb52784 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 20 Aug 2022 15:06:25 +0800 Subject: [PATCH] Add unit test --- .../SqlServerTest/UnitTest/UCodeFirst.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCodeFirst.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCodeFirst.cs index c941f6c9e..77b0a05c7 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UCodeFirst.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCodeFirst.cs @@ -105,7 +105,27 @@ namespace OrmTest var list3=db.Queryable().ToList(); - //db.Insertable>(new ApiLog(1) { RequestUser="a"}).ExecuteCommand(); + + db.MappingTables = new MappingTableList(); + db.MappingTables.Add("a", "b"); + db.MappingTables.Add("c", "d"); + db.CodeFirst.As("ApiLog0001").InitTables(); + db.Queryable().AS("ApiLog0001").ToList(); + db.CodeFirst.As("ApiLog0002").InitTables(); + db.Queryable().AS("ApiLog0002").ToList(); + db.Queryable().ToList(); + if (db.MappingTables.Count != 2) + { + throw new Exception("unit error"); + } + if (db.MappingTables.First(it=>it.EntityName=="a").DbTableName!="b") + { + throw new Exception("unit error"); + } + if (db.MappingTables.First(it => it.EntityName == "c").DbTableName != "d") + { + throw new Exception("unit error"); + } } ///