mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
update unit test
This commit is contained in:
parent
c13dd5ce98
commit
30b0976ebf
@ -10,6 +10,14 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
|
|
||||||
public static void Tran()
|
public static void Tran()
|
||||||
|
{
|
||||||
|
Tran1();
|
||||||
|
Tran2();
|
||||||
|
Tran3().Wait();
|
||||||
|
Tran4().Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Tran1()
|
||||||
{
|
{
|
||||||
var db = Db;
|
var db = Db;
|
||||||
int oldCount = GetCount(db);
|
int oldCount = GetCount(db);
|
||||||
@ -25,6 +33,59 @@ namespace OrmTest
|
|||||||
throw new Exception("NewUnitTest Tran ");
|
throw new Exception("NewUnitTest Tran ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static void Tran2()
|
||||||
|
{
|
||||||
|
var db = Db;
|
||||||
|
int oldCount = GetCount(db);
|
||||||
|
Console.WriteLine(oldCount);
|
||||||
|
db.UseTran(()=>{
|
||||||
|
|
||||||
|
db.Deleteable<Order>().ExecuteCommand();
|
||||||
|
Console.WriteLine(GetCount(db));
|
||||||
|
throw new Exception("");
|
||||||
|
});
|
||||||
|
int newCount = GetCount(db);
|
||||||
|
Console.WriteLine(newCount);
|
||||||
|
if (newCount != oldCount)
|
||||||
|
{
|
||||||
|
throw new Exception("NewUnitTest Tran ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static async Task Tran3()
|
||||||
|
{
|
||||||
|
var db = Db;
|
||||||
|
int oldCount = GetCount(db);
|
||||||
|
Console.WriteLine(oldCount);
|
||||||
|
db.BeginTran();
|
||||||
|
await db.Deleteable<Order>().ExecuteCommandAsync();
|
||||||
|
Console.WriteLine(GetCount(db));
|
||||||
|
db.RollbackTran();
|
||||||
|
int newCount = GetCount(db);
|
||||||
|
Console.WriteLine(newCount);
|
||||||
|
if (newCount != oldCount)
|
||||||
|
{
|
||||||
|
throw new Exception("NewUnitTest Tran ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static async Task Tran4()
|
||||||
|
{
|
||||||
|
var db = Db;
|
||||||
|
int oldCount = GetCount(db);
|
||||||
|
Console.WriteLine(oldCount);
|
||||||
|
await db.UseTranAsync( async () => {
|
||||||
|
|
||||||
|
await db.Deleteable<Order>().ExecuteCommandAsync();
|
||||||
|
Console.WriteLine(GetCount(db));
|
||||||
|
throw new Exception("");
|
||||||
|
});
|
||||||
|
int newCount = GetCount(db);
|
||||||
|
Console.WriteLine(newCount);
|
||||||
|
if (newCount != oldCount)
|
||||||
|
{
|
||||||
|
throw new Exception("NewUnitTest Tran ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static int GetCount(SqlSugar.SqlSugarClient db)
|
private static int GetCount(SqlSugar.SqlSugarClient db)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user