Add unit test

This commit is contained in:
sunkaixuan 2022-11-07 18:16:58 +08:00
parent 908dc7562a
commit 990d471eca
3 changed files with 48 additions and 3 deletions

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
namespace OrmTest
{
public class Unit01
{
public static void Init()
{
var client = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;",
DbType = DbType.QuestDB,
LanguageType = LanguageType.Chinese,
IsAutoCloseConnection = true
});
client.CodeFirst.InitTables<TestUserEntity>();
TestUserEntity[] users = new TestUserEntity[]
{
new TestUserEntity(){Name="zhangsan",cate="a" },
new TestUserEntity(){Name="lisi",cate="b" }
};
client.Queryable<TestUserEntity>().Where(u => u.cate.Equals("a")).ToList();
client.Queryable<TestUserEntity>().Where(u => u.cate.Equals(users[0].cate)).ToList();
}
[SugarTable("TestUser")]
public class TestUserEntity
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
public string Name { get; set; }
public string cate { get; set; }
}
}
}

View File

@ -25,9 +25,10 @@ namespace OrmTest
DemoE_CodeFirst.Init(); DemoE_CodeFirst.Init();
DemoF_Utilities.Init(); DemoF_Utilities.Init();
DemoG_SimpleClient.Init(); DemoG_SimpleClient.Init();
//Unit test Unit01.Init();
Console.WriteLine("all successfully."); Console.WriteLine("all successfully.");
Console.ReadKey(); Console.ReadKey();

View File

@ -64,6 +64,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Config.cs" /> <Compile Include="Config.cs" />
<Compile Include="Demo\Unit01.cs" />
<Compile Include="Demo\Demo0_SqlSugarClient.cs" /> <Compile Include="Demo\Demo0_SqlSugarClient.cs" />
<Compile Include="Demo\Demo1_Queryable.cs" /> <Compile Include="Demo\Demo1_Queryable.cs" />
<Compile Include="Demo\Demo2_Updateable.cs" /> <Compile Include="Demo\Demo2_Updateable.cs" />