Add user test case

This commit is contained in:
sunkaixuan
2024-02-24 17:22:00 +08:00
parent 4b334b47e5
commit 4c7e794c9e
3 changed files with 44 additions and 0 deletions

View File

@@ -134,6 +134,7 @@
<Compile Include="UserTestCases\UnitTest\Unit001.cs" />
<Compile Include="UserTestCases\UnitTest\Unitadfaafsd.cs" />
<Compile Include="UserTestCases\UnitTest\Unitadfafafasd.cs" />
<Compile Include="UserTestCases\UnitTest\UnitAny.cs" />
<Compile Include="UserTestCases\UnitTest\UnitByteArray.cs" />
<Compile Include="UserTestCases\UnitTest\Unitdfadfa.cs" />
<Compile Include="UserTestCases\UnitTest\UnitPgSplit.cs" />

View File

@@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
UnitAny.Init();
Unitadfafafasd.Init();
UintOneToOneDto.Init();
Unitadfaafsd.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
{
internal class UnitAny
{
public static void Init()
{
var db = NewUnitTest.Db;
db.CodeFirst.InitTables<UintAnyModel>();
var id=db.Insertable(new UintAnyModel() {
Name="a"
}).ExecuteReturnIdentity();
if (db.Queryable<UintAnyModel>().Any(it => it.Id == id) == false)
{
throw new Exception("unit error");
}
if (db.Queryable<UintAnyModel>().Any(it => it.Id == 971151111) == true)
{
throw new Exception("unit error");
}
if (db.Queryable<UintAnyModel>().AnyAsync(it => it.Id == id).GetAwaiter().GetResult() == false)
{
throw new Exception("unit error");
}
if (db.Queryable<UintAnyModel>().AnyAsync(it => it.Id == 971151111).GetAwaiter().GetResult() == true)
{
throw new Exception("unit error");
}
}
public class UintAnyModel
{
[SqlSugar.SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
public int Id { get; set; }
public string Name { get; set; }
}
}
}