Add unit test

This commit is contained in:
sunkaixuan 2023-09-13 13:49:23 +08:00
parent 8f04739e20
commit d435b21326

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;
@ -16,16 +17,16 @@ namespace OrmTest
var address = new UnitAddress011 var address = new UnitAddress011
{ {
Street = "123 Main Street", Street = "123 Main Street",
CityId=1,Persons=new List<UnitPerson011>() { CityId = 1, Persons = new List<UnitPerson011>() {
new UnitPerson011 new UnitPerson011
{ {
Name = "John Doe" Name = "John Doe"
} }
}, },
City=new UnitCity() { City = new UnitCity() {
AddressId=1, AddressId = 1,
Name="city" Name = "city"
} }
}; };
@ -40,8 +41,24 @@ namespace OrmTest
db.DeleteNav(address).IncludeByNameString("Persons") db.DeleteNav(address).IncludeByNameString("Persons")
.IncludeByNameString("City").ExecuteCommand(); .IncludeByNameString("City").ExecuteCommand();
db.CodeFirst.InitTables<UnitTesta>();
db.CurrentConnectionConfig.MoreSettings = new SqlSugar.ConnMoreSettings() { EnableCodeFirstUpdatePrecision = true };
db.CodeFirst.InitTables<UNITTESTA>();
var data= db.DbMaintenance.GetColumnInfosByTableName("UNITTESTA", false);
if (data.First().DecimalDigits != 6)
{
throw new Exception("unit error");
}
}
public class UnitTesta
{
[SqlSugar.SugarColumn(Length =18,DecimalDigits =4)]
public decimal xx { get; set; }
}
public class UNITTESTA
{
[SqlSugar.SugarColumn(Length = 18, DecimalDigits = 6)]
public decimal xx { get; set; }
} }
[SqlSugar.SugarTable("UnitPerson01x1")] [SqlSugar.SugarTable("UnitPerson01x1")]