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
85053943f2
commit
76fa3307ee
@ -111,6 +111,7 @@
|
|||||||
<Compile Include="UnitTest\UCustom020.cs" />
|
<Compile Include="UnitTest\UCustom020.cs" />
|
||||||
<Compile Include="UnitTest\UCustom019.cs" />
|
<Compile Include="UnitTest\UCustom019.cs" />
|
||||||
<Compile Include="UnitTest\UintDynamic.cs" />
|
<Compile Include="UnitTest\UintDynamic.cs" />
|
||||||
|
<Compile Include="UnitTest\ULock.cs" />
|
||||||
<Compile Include="UnitTest\UNavDynamic111N.cs" />
|
<Compile Include="UnitTest\UNavDynamic111N.cs" />
|
||||||
<Compile Include="UnitTest\UnitManyToMany2.cs" />
|
<Compile Include="UnitTest\UnitManyToMany2.cs" />
|
||||||
<Compile Include="UnitTest\UnitManyToMany.cs" />
|
<Compile Include="UnitTest\UnitManyToMany.cs" />
|
||||||
|
@ -31,7 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
ULock.Init();
|
||||||
UnitManyToMany2.Init();
|
UnitManyToMany2.Init();
|
||||||
UOneManyMany5.init();
|
UOneManyMany5.init();
|
||||||
UOneManyMany4.init();
|
UOneManyMany4.init();
|
||||||
|
46
Src/Asp.Net/SqlServerTest/UnitTest/ULock.cs
Normal file
46
Src/Asp.Net/SqlServerTest/UnitTest/ULock.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public class ULock
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var db = NewUnitTest.Db;
|
||||||
|
db.CodeFirst.InitTables<ULockEntity>();
|
||||||
|
db.DbMaintenance.TruncateTable<ULockEntity>();
|
||||||
|
var id=db.Insertable(new ULockEntity()
|
||||||
|
{
|
||||||
|
Name = "oldName",
|
||||||
|
}).ExecuteReturnIdentity();
|
||||||
|
|
||||||
|
var data = db.Updateable(new ULockEntity()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = "newname",
|
||||||
|
Ver=0
|
||||||
|
}).ExecuteCommandWithOptLock();
|
||||||
|
if (data != 1) { throw new Exception("unit error"); };
|
||||||
|
var data2 = db.Updateable(new ULockEntity()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = "newname2",
|
||||||
|
Ver = 0
|
||||||
|
}).ExecuteCommandWithOptLock();
|
||||||
|
if (data2 != 0) { throw new Exception("unit error"); };
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ULockEntity
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
[SqlSugar.SugarColumn(IsEnableUpdateVersionValidation = true)]
|
||||||
|
public long Ver { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user