Browse Source

Add unit test

pull/32/head
sunkaixuan 2 years ago
parent
commit
5ab41ef8d5
  1. 1
      Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs
  2. 102
      Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitCustom020.cs

1
Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs

@ -31,6 +31,7 @@ namespace OrmTest
} }
public static void Init() public static void Init()
{ {
UnitCustom020.Init();
UnitSubToList.Init(); UnitSubToList.Init();
UJsonsdafa.Init(); UJsonsdafa.Init();
UOneManyMany.init(); UOneManyMany.init();

102
Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitCustom020.cs

@ -0,0 +1,102 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using System.Xml.Linq;
namespace OrmTest
{
internal class UnitCustom020
{
public static void Init()
{
var db = NewUnitTest.Db;
//建表
if (!db.DbMaintenance.IsAnyTable("Kc_ygzlmx", false))
{
db.CodeFirst.InitTables<Kc_ygzlmx>();
}
//用例代码
//var result = db.Insertable(new TM.Kcgl.Kc_ygzlmx() { Pkid = "EE2C5971978248498AE378DD86518096", Gzlbh = "B198E22CA25842DB81D1500637DDF147", Jsbh = "JS00C49ACC45C244AD9E582A9C144936", Zc = 1, Jxcs = 1, Jxss = 2 }).ExecuteCommand();//用例代码
// result = db.Insertable(new TM.Kcgl.Kc_ygzlmx() { Pkid = "EE2C5971978248498AE378DD86518096", Gzlbh = "B198E22CA25842DB81D1500637DDF147", Jsbh = "JS00C49ACC45C244AD9E582A9C144936", Zc = 2, Jxcs = 2, Jxss = 4 }).ExecuteCommand();//用例代码
// 修改表
Kc_ygzlmx mx = new Kc_ygzlmx();
mx.Gzlbh = "B198E22CA25842DB81D1500637DDF147";
mx.Zc = 1;
mx.Jxcs = 10;
mx.Jxss = 10;
db.Updateable(mx)
.UpdateColumns(new string[] { "Jxcs", "Jxss" })
.WhereColumns(new string[] { "Gzlbh", "Zc" })
.ExecuteCommand();
}
/// <summary>
/// 月工作量明细Kc_ygzlmx
/// </summary>
public class Kc_ygzlmx
{
#region 构造函数
public Kc_ygzlmx()
{
}
#endregion
#region 属性
/// <summary>
/// 序号
/// </summary>
[StringLength(32)]
[Display(Name = "序号")]
[Required(ErrorMessage = "序号是必填项")]
[SugarColumn(IsPrimaryKey = true)]
public string Pkid { get; set; }
/// <summary>
/// 工作量编号
/// </summary>
[StringLength(32)]
[Display(Name = "工作量编号")]
[Required(ErrorMessage = "工作量编号是必填项")]
public string Gzlbh { get; set; }
/// <summary>
/// 教师编号
/// </summary>
[StringLength(32)]
[Display(Name = "教师编号")]
[Required(ErrorMessage = "教师编号是必填项")]
public string Jsbh { get; set; }
/// <summary>
/// 周次
/// </summary>
[Display(Name = "周次")]
[Required(ErrorMessage = "周次是必填项")]
public int Zc { get; set; } = 0;
/// <summary>
/// 本周教学次数
/// </summary>
[Display(Name = "本周教学次数")]
[Required(ErrorMessage = "本周教学次数是必填项")]
public int Jxcs { get; set; } = 0;
/// <summary>
/// 本周教学时数
/// </summary>
[Display(Name = "本周教学时数")]
[Required(ErrorMessage = "本周教学时数是必填项")]
public int Jxss { get; set; } = 0;
#endregion
}
}
}
Loading…
Cancel
Save