mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Add unit test
This commit is contained in:
parent
a4ad84c8f3
commit
3e4ede5f2a
@ -107,6 +107,7 @@
|
|||||||
<Compile Include="UnitTest\UCustom012.cs" />
|
<Compile Include="UnitTest\UCustom012.cs" />
|
||||||
<Compile Include="UnitTest\UCustom014.cs" />
|
<Compile Include="UnitTest\UCustom014.cs" />
|
||||||
<Compile Include="UnitTest\UCustom015.cs" />
|
<Compile Include="UnitTest\UCustom015.cs" />
|
||||||
|
<Compile Include="UnitTest\UCustom016.cs" />
|
||||||
<Compile Include="UnitTest\USave.cs" />
|
<Compile Include="UnitTest\USave.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
UCustom016.Init();
|
||||||
UCustom08.Init();
|
UCustom08.Init();
|
||||||
UCustom012.Init();
|
UCustom012.Init();
|
||||||
UCustom014.Init();
|
UCustom014.Init();
|
||||||
|
74
Src/Asp.Net/PgSqlTest/UnitTest/UCustom016.cs
Normal file
74
Src/Asp.Net/PgSqlTest/UnitTest/UCustom016.cs
Normal file
@ -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<TestEntity>
|
||||||
|
{
|
||||||
|
new TestEntity
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Data1 = null,
|
||||||
|
Data2 = null
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var list2 = new List<TestEntity>
|
||||||
|
{
|
||||||
|
new TestEntity
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
Data1 = null,
|
||||||
|
Data2 = null
|
||||||
|
},
|
||||||
|
new TestEntity
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
Data1 = null,
|
||||||
|
Data2 = null
|
||||||
|
},
|
||||||
|
};
|
||||||
|
db.CodeFirst.InitTables<TestEntity>();
|
||||||
|
db.DbMaintenance.TruncateTable<TestEntity>();
|
||||||
|
db.Insertable(list0).ExecuteCommand();
|
||||||
|
db.Insertable(list1).ExecuteCommand ();
|
||||||
|
db.Insertable(list2).ExecuteCommand();
|
||||||
|
var list3 = db.Queryable<TestEntity>().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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user