From 5ab41ef8d57ee2de1dfbc511914e5ad2d0ae9cc1 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 18 Apr 2023 17:22:06 +0800 Subject: [PATCH] Add unit test --- .../SqlSeverTest/UnitTest/Main.cs | 1 + .../SqlSeverTest/UnitTest/UnitCustom020.cs | 102 ++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitCustom020.cs diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs index 31fee3711..5ea2a923d 100644 --- a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs +++ b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + UnitCustom020.Init(); UnitSubToList.Init(); UJsonsdafa.Init(); UOneManyMany.init(); diff --git a/Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitCustom020.cs b/Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitCustom020.cs new file mode 100644 index 000000000..b5ecd1313 --- /dev/null +++ b/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(); + } + + //用例代码 + //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(); + } + + /// + /// 月工作量明细Kc_ygzlmx + /// + public class Kc_ygzlmx + { + #region 构造函数 + + public Kc_ygzlmx() + { + } + + #endregion + + #region 属性 + + /// + /// 序号 + /// + [StringLength(32)] + [Display(Name = "序号")] + [Required(ErrorMessage = "序号是必填项")] + [SugarColumn(IsPrimaryKey = true)] + public string Pkid { get; set; } + + /// + /// 工作量编号 + /// + [StringLength(32)] + [Display(Name = "工作量编号")] + [Required(ErrorMessage = "工作量编号是必填项")] + public string Gzlbh { get; set; } + + /// + /// 教师编号 + /// + [StringLength(32)] + [Display(Name = "教师编号")] + [Required(ErrorMessage = "教师编号是必填项")] + public string Jsbh { get; set; } + + /// + /// 周次 + /// + [Display(Name = "周次")] + [Required(ErrorMessage = "周次是必填项")] + public int Zc { get; set; } = 0; + + /// + /// 本周教学次数 + /// + [Display(Name = "本周教学次数")] + [Required(ErrorMessage = "本周教学次数是必填项")] + public int Jxcs { get; set; } = 0; + + /// + /// 本周教学时数 + /// + [Display(Name = "本周教学时数")] + [Required(ErrorMessage = "本周教学时数是必填项")] + public int Jxss { get; set; } = 0; + + #endregion + } + } +}