Add unit test

This commit is contained in:
sunkaixuan 2022-05-13 20:36:37 +08:00
parent b196b53d8b
commit e9a469baad
3 changed files with 44 additions and 0 deletions

View File

@ -95,6 +95,7 @@
<Compile Include="Models\OrderItem.cs" /> <Compile Include="Models\OrderItem.cs" />
<Compile Include="Demo\Demo0_SqlSugarClient.cs" /> <Compile Include="Demo\Demo0_SqlSugarClient.cs" />
<Compile Include="Models\ViewOrder.cs" /> <Compile Include="Models\ViewOrder.cs" />
<Compile Include="UnitTest\UByteArray.cs" />
<Compile Include="UnitTest\UIncludesBigData.cs" /> <Compile Include="UnitTest\UIncludesBigData.cs" />
<Compile Include="UnitTest\UCustom020.cs" /> <Compile Include="UnitTest\UCustom020.cs" />
<Compile Include="UnitTest\UCustom019.cs" /> <Compile Include="UnitTest\UCustom019.cs" />

View File

@ -31,6 +31,7 @@ namespace OrmTest
} }
public static void Init() public static void Init()
{ {
UByteArray.Init();
UCustom020.Init(); UCustom020.Init();
UCustom019.Init(); UCustom019.Init();
UnitManyToMany.Init(); UnitManyToMany.Init();

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class UByteArray
{
public static void Init()
{
var db = NewUnitTest.Db;
db.CodeFirst.InitTables<UnitBytePk>();
db.DbMaintenance.TruncateTable<UnitBytePk>();
db.Insertable(new UnitBytePk()
{
id=new byte[] { 1,2,3},
name="a"
}).ExecuteCommand();
db.Insertable(new UnitBytePk()
{
id = new byte[] { 2, 2, 3 },
name = "a2"
}).ExecuteCommand();
var x=db.Storageable(new UnitBytePk()
{
id =new byte []{ 1, 2, 3 },
name = "aaa"
}).ToStorage();
var count=x.AsUpdateable.ExecuteCommand();
SqlSugar.Check.Exception(count == 3, "unit error");
}
public class UnitBytePk
{
[SqlSugar.SugarColumn(IsPrimaryKey =true,ColumnDataType ="binary(20)")]
public byte[] id { get; set; }
public string name { get; set; }
}
}
}