Update unit test

This commit is contained in:
sunkaixuan
2022-03-23 11:01:17 +08:00
parent ebe0a7b31b
commit 2d41e1ed35
8 changed files with 128 additions and 0 deletions

View File

@@ -86,6 +86,7 @@
<Compile Include="UnitTest\UBulkCopy.cs" />
<Compile Include="UnitTest\UCodeFirst.cs" />
<Compile Include="UnitTest\UCustom01.cs" />
<Compile Include="UnitTest\UCustom011.cs" />
<Compile Include="UnitTest\UCustom02.cs" />
<Compile Include="UnitTest\UInsert.cs" />
<Compile Include="UnitTest\UJson.cs" />

View File

@@ -0,0 +1,31 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class UCustom011
{
public static void Init()
{
var db = NewUnitTest.Db;
db.Queryable<Order>().Where(it => (it.CreateTime - SqlFunc.GetDate()).TotalDays > 1).ToList();
var x1=db.Queryable<Order>().Select(it => (DateTime.Now - SqlFunc.GetDate().AddYears(-1)).TotalDays).ToList();
var x2 = db.Queryable<Order>().Select(it => (DateTime.Now - SqlFunc.GetDate().AddDays(-1)).TotalHours).ToList();
var x3 = db.Queryable<Order>().Select(it => (DateTime.Now - SqlFunc.GetDate().AddHours(-1)).TotalMinutes).ToList();
var x4 = db.Queryable<Order>().Select(it => (DateTime.Now - SqlFunc.GetDate().AddMinutes(-1)).TotalSeconds).ToList();
if (x1.Any())
{
Check.Exception(x1.First()!=365, "unit error . UCustom011");
Check.Exception(x2.First() != 24, "unit error . UCustom011");
Check.Exception(x3.First() != 60, "unit error . UCustom011");
Check.Exception(x4.First() != 60, "unit error . UCustom011");
}
}
}
}