mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Add unit test
This commit is contained in:
parent
077cbc7e71
commit
e946bcc1b1
Src/Asp.Net/SqliteTest
@ -90,6 +90,7 @@
|
||||
<Compile Include="UnitTest\Models\Room.cs" />
|
||||
<Compile Include="UnitTest\Models\School.cs" />
|
||||
<Compile Include="UnitTest\Models\Student.cs" />
|
||||
<Compile Include="UnitTest\Unitadfaafsd.cs" />
|
||||
<Compile Include="UnitTest\UnitFilterdafa.cs" />
|
||||
<Compile Include="UnitTest\Models\BilPayment.cs" />
|
||||
<Compile Include="UnitTest\UInsert3.cs" />
|
||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
Unitadfaafsd.Init();
|
||||
UFilter2.Init();
|
||||
UinitCustomConvert.Init();
|
||||
UnitNavUpdatee12.Init();
|
||||
|
100
Src/Asp.Net/SqliteTest/UnitTest/Unitadfaafsd.cs
Normal file
100
Src/Asp.Net/SqliteTest/UnitTest/Unitadfaafsd.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace OrmTest
|
||||
{
|
||||
internal class Unitadfaafsd
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
SqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = Config.ConnectionString,
|
||||
DbType = DbType.Sqlite,
|
||||
IsAutoCloseConnection = true
|
||||
},
|
||||
db =>
|
||||
{
|
||||
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql);//输出sql,查看执行sql 性能无影响
|
||||
};
|
||||
});
|
||||
_db.CodeFirst.InitTables<JqdsrdbEntity, JqdsrgxbEntity>();
|
||||
_db.InsertNav(new JqdsrdbEntity()
|
||||
{
|
||||
Jqdsrdbh = "a",
|
||||
Jqdsrgxbs = new List<JqdsrgxbEntity>()
|
||||
{
|
||||
new JqdsrgxbEntity(){
|
||||
Jqdsrdbh= "a",
|
||||
Id= 1,
|
||||
Sfmc= "a",
|
||||
Sf="a"
|
||||
}
|
||||
}
|
||||
}).Include(x => x.Jqdsrgxbs).ExecuteCommand();
|
||||
var items = _db.Queryable<JqdsrdbEntity>()
|
||||
.Includes(dsr => dsr.Jqdsrgxbs)
|
||||
.Select((dsr) =>
|
||||
new Resp
|
||||
{
|
||||
Sf = dsr.Jqdsrgxbs.Select(sf => sf.Sfmc),
|
||||
IsShowOperationButton = true
|
||||
},
|
||||
isAutoFill: true)
|
||||
.ToListAsync().GetAwaiter().GetResult();
|
||||
if (items.First().Jqdsrdbh != "a" || items.First().IsShowOperationButton == false ||
|
||||
items.First().Sf.Count() == 0)
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
}
|
||||
}
|
||||
[SugarTable("jqdsrdb")]
|
||||
public class JqdsrdbEntity
|
||||
{
|
||||
|
||||
[SugarColumn(ColumnName = "jqdsrdbh", IsPrimaryKey = true)]
|
||||
public string Jqdsrdbh { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToMany, nameof(JqdsrgxbEntity.Jqdsrdbh))]
|
||||
public List<JqdsrgxbEntity> Jqdsrgxbs { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[SugarTable("jqdsrgxb")]
|
||||
public class JqdsrgxbEntity
|
||||
{
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "sf")]
|
||||
public string Sf { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "sfmc")]
|
||||
public string Sfmc { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "jqdsrdbh")]
|
||||
public string Jqdsrdbh { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class Resp
|
||||
{
|
||||
public string Jqdsrdbh { get; set; }
|
||||
public bool IsShowOperationButton { get; set; }
|
||||
|
||||
public IEnumerable<string> Sf { get; set; }
|
||||
}
|
||||
|
||||
public class JqdsrgxbModel
|
||||
{
|
||||
public string Sf { get; set; }
|
||||
|
||||
public string Sfmc { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user