Add unit test

This commit is contained in:
sunkaixuan 2022-12-15 17:21:15 +08:00
parent fc40a77097
commit 5ff7554497
3 changed files with 51 additions and 0 deletions

View File

@ -102,6 +102,7 @@
<Compile Include="UnitTest\Updateable.cs" />
<Compile Include="UnitTest\UQueryable.cs" />
<Compile Include="UnitTest\UQueryableAsync.cs" />
<Compile Include="UnitTest\USaveable.cs" />
<Compile Include="UnitTest\UThread.cs" />
<Compile Include="UnitTest\UThread2.cs" />
<Compile Include="UnitTest\UThread3.cs" />

View File

@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
USaveable.Init();
UnitSubToList.Init();
UnitByteArray.Init();
Unit01.Init();

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
internal class USaveable
{
public static void Init()
{
List();
T();
}
private static void T()
{
var db = NewUnitTest.Db;
object o1 = new Order() { Id = 1, CreateTime = DateTime.Now, CustomId = 1, Name = "a", Price = 1 };
db.StorageableByObject(o1).ExecuteCommand();
object o2 = new Order() { Id = 0, CreateTime = DateTime.Now, CustomId = 1, Name = "a", Price = 1 };
db.StorageableByObject(o2).ExecuteCommand();
}
private static void List()
{
var db = NewUnitTest.Db;
List<object> o1 = new List<object>() { new Order() { Id = 0, CreateTime = DateTime.Now, CustomId = 1, Name = "a", Price = 1 } };
db.StorageableByObject(o1).ExecuteCommand();
o1 = new List<object>() { new Order() { Id = 1, CreateTime = DateTime.Now, CustomId = 1, Name = "a", Price = 1 } };
db.StorageableByObject(o1).ExecuteCommand();
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("insert update");
List<object> o2 = new List<object>() { new Order() { Id = 1, CreateTime = DateTime.Now, CustomId = 1, Name = "a", Price = 1 }, new Order() { Id = 0, CreateTime = DateTime.Now, CustomId = 1, Name = "a", Price = 1 } };
var x = db.StorageableByObject(o2).ToStorage();
x.AsInsertable.ExecuteCommand();
x.AsUpdateable.ExecuteCommand();
object o = db.Queryable<Order>().ToList();
db.StorageableByObject(o).ExecuteCommand();
}
}
}