From 3e4ede5f2a1e0600540a37de49bee44b4be56bd2 Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Tue, 14 Jun 2022 18:59:33 +0800
Subject: [PATCH] Add unit test
---
Src/Asp.Net/PgSqlTest/PgSqlTest.csproj | 1 +
Src/Asp.Net/PgSqlTest/UnitTest/Main.cs | 1 +
Src/Asp.Net/PgSqlTest/UnitTest/UCustom016.cs | 74 ++++++++++++++++++++
3 files changed, 76 insertions(+)
create mode 100644 Src/Asp.Net/PgSqlTest/UnitTest/UCustom016.cs
diff --git a/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj b/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj
index b7e8d1870..513b78940 100644
--- a/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj
+++ b/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj
@@ -107,6 +107,7 @@
+
diff --git a/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs b/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs
index e71e0c1f0..2c951a30a 100644
--- a/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs
+++ b/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs
@@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
+ UCustom016.Init();
UCustom08.Init();
UCustom012.Init();
UCustom014.Init();
diff --git a/Src/Asp.Net/PgSqlTest/UnitTest/UCustom016.cs b/Src/Asp.Net/PgSqlTest/UnitTest/UCustom016.cs
new file mode 100644
index 000000000..69baf5bc9
--- /dev/null
+++ b/Src/Asp.Net/PgSqlTest/UnitTest/UCustom016.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SqlSugar;
+namespace OrmTest
+{
+
+ public class UCustom016
+ {
+ public static void Init()
+ {
+ var db = NewUnitTest.Db;
+ var list0 = new TestEntity
+ {
+ Id = 1,
+ Data1 = null,
+ Data2 = null
+ };
+ var list1 = new List
+ {
+ new TestEntity
+ {
+ Id = 2,
+ Data1 = null,
+ Data2 = null
+ },
+ };
+ var list2 = new List
+ {
+ new TestEntity
+ {
+ Id = 3,
+ Data1 = null,
+ Data2 = null
+ },
+ new TestEntity
+ {
+ Id = 4,
+ Data1 = null,
+ Data2 = null
+ },
+ };
+ db.CodeFirst.InitTables();
+ db.DbMaintenance.TruncateTable();
+ db.Insertable(list0).ExecuteCommand();
+ db.Insertable(list1).ExecuteCommand ();
+ db.Insertable(list2).ExecuteCommand();
+ var list3 = db.Queryable().ToList();
+ if (list3.First().Data1 != null)
+ {
+ throw new Exception("unit error");
+ }
+ }
+ public enum TestEnum
+ {
+ A = 1,
+ B = 2,
+ C = 3,
+ D = 4,
+ }
+ [SugarTable("UnitNullenum1")]
+ public class TestEntity
+ {
+ [SugarColumn(IsPrimaryKey = true)]
+ public long Id { get; set; }
+ [SugarColumn(IsNullable =true)]
+ public TestEnum? Data1 { get; set; }
+ [SugarColumn(IsNullable = true)]
+ public int? Data2 { get; set; }
+ }
+ }
+}