mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Add unit test
This commit is contained in:
parent
bad86d20fc
commit
df443a8a20
@ -97,6 +97,7 @@
|
||||
<Compile Include="Models\OrderItem.cs" />
|
||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\UnitEnum22.cs" />
|
||||
<Compile Include="UnitTest\UCustom025.cs" />
|
||||
<Compile Include="UnitTest\Models\ImsBillDtl.cs" />
|
||||
<Compile Include="UnitTest\Models\ImsBillDtlStk.cs" />
|
||||
|
@ -31,7 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
|
||||
UnitEnum22.Init();
|
||||
UCustom025.Init();
|
||||
UnitTestConfigQuery.Init();
|
||||
UnitSub.Init();
|
||||
|
62
Src/Asp.Net/SqlServerTest/UnitTest/UnitEnum22.cs
Normal file
62
Src/Asp.Net/SqlServerTest/UnitTest/UnitEnum22.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
namespace OrmTest
|
||||
{
|
||||
public class UnitEnum22
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var _db = NewUnitTest.Db;
|
||||
_db.CodeFirst.InitTables<TestTbl>();
|
||||
|
||||
|
||||
|
||||
TestTbl updateTestTbl = new TestTbl()
|
||||
{
|
||||
Name = DateTime.Now.Ticks.ToString(),
|
||||
Status=Status.B
|
||||
};
|
||||
var success = _db.Updateable(updateTestTbl)
|
||||
.IgnoreColumns(ignoreAllNullColumns: true, ignoreAllDefaultValue: true)
|
||||
.Where(x => x.Id == 1)
|
||||
.ToSql ();
|
||||
if (!success.Key.Contains("status")) { throw new Exception("unit error"); }
|
||||
|
||||
updateTestTbl.Status = Status.A;
|
||||
|
||||
var success2 = _db.Updateable(updateTestTbl)
|
||||
.IgnoreColumns(ignoreAllNullColumns: true, ignoreAllDefaultValue: true)
|
||||
.Where(x => x.Id == 1)
|
||||
.ToSql();
|
||||
|
||||
if (success2.Key.Contains("status")) { throw new Exception("unit error"); }
|
||||
|
||||
//Assert.NotNull(testTbl);
|
||||
//Assert.Equal(flag, testTbl.Flag);
|
||||
//Assert.Equal(status, testTbl.Status);
|
||||
|
||||
}
|
||||
|
||||
public enum Status
|
||||
{
|
||||
A = 0,
|
||||
B = 1
|
||||
}
|
||||
[SugarTable("test_tbl")]
|
||||
public sealed class TestTbl
|
||||
{
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
[SugarColumn(ColumnName = "name")]
|
||||
public string Name { get; set; }
|
||||
[SugarColumn(ColumnName = "flag")]
|
||||
public int Flag { get; set; }
|
||||
[SugarColumn(ColumnName = "status")]
|
||||
public Status Status { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user