From 29253789a2e66439134774a4f58377018f0c8160 Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Mon, 14 Nov 2022 01:33:42 +0800
Subject: [PATCH] Add unit test
---
Src/Asp.Net/PgSqlTest/PgSqlTest.csproj | 1 +
Src/Asp.Net/PgSqlTest/UnitTest/Main.cs | 1 +
.../PgSqlTest/UnitTest/UnitByteArray.cs | 40 +++++++++++++++++++
3 files changed, 42 insertions(+)
create mode 100644 Src/Asp.Net/PgSqlTest/UnitTest/UnitByteArray.cs
diff --git a/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj b/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj
index a0715f854..c9c33e41d 100644
--- a/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj
+++ b/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj
@@ -104,6 +104,7 @@
+
diff --git a/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs b/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs
index d246d9e98..a4b9f72df 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()
{
+ UnitByteArray.Init();
Unit001.Init();
UnitPgSplit.Init();
UJsonFunc.Init();
diff --git a/Src/Asp.Net/PgSqlTest/UnitTest/UnitByteArray.cs b/Src/Asp.Net/PgSqlTest/UnitTest/UnitByteArray.cs
new file mode 100644
index 000000000..f9dcea95e
--- /dev/null
+++ b/Src/Asp.Net/PgSqlTest/UnitTest/UnitByteArray.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest
+{
+ public class UnitByteArray
+ {
+ public static void Init()
+ {
+ var db = NewUnitTest.Db;
+ var b=new byte[1024];
+ b[0] = 1;
+ b[1] = 2;
+ b[1023] = 2;
+ if (db.DbMaintenance.IsAnyTable("UnitBytes001231",false))
+ {
+ db.DbMaintenance.DropTable();
+ }
+ db.CodeFirst.InitTables();
+ db.DbMaintenance.TruncateTable();
+ db.Insertable(new UnitBytes001231() { array = b }).ExecuteCommand();
+ var list4 = db.Queryable().First().array;
+ var old = string.Join(",", b);
+ var newstr = string.Join(",", list4);
+ if (old != newstr)
+ {
+ throw new Exception("unit error");
+ }
+ Console.WriteLine("#### CodeFirst end ####");
+ }
+ }
+ public class UnitBytes001231
+ {
+ public byte[] array { get; set; }
+ }
+
+}