You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using SqlSugar;
|
|
using System.Linq;
|
|
namespace OrmTest.UnitTest
|
|
{
|
|
public class UnitTestBase
|
|
{
|
|
public int Count { get; set; }
|
|
private DateTime BeginTime { get; set; }
|
|
private DateTime EndTime { get; set; }
|
|
|
|
public void Begin()
|
|
{
|
|
this.BeginTime = DateTime.Now;
|
|
}
|
|
|
|
public void End(string title)
|
|
{
|
|
this.EndTime = DateTime.Now;
|
|
Console.WriteLine(title + " \r\nCount: " + this.Count + "\r\nTime: " + (this.EndTime - this.BeginTime).TotalSeconds + " Seconds \r\n");
|
|
}
|
|
|
|
internal void Check(string value, List<SugarParameter> pars, string validValue, List<SugarParameter> validPars, string errorMessage)
|
|
{
|
|
if (value.Trim() != validValue.Trim())
|
|
{
|
|
throw new Exception(errorMessage);
|
|
}
|
|
if (pars != null && pars.Count > 0)
|
|
{
|
|
if (pars.Count != validPars.Count)
|
|
{
|
|
throw new Exception(errorMessage);
|
|
}
|
|
else
|
|
{
|
|
foreach (var item in pars)
|
|
{
|
|
if (!validPars.Any(it => it.ParameterName.Equals(item.ParameterName) && it.Value.ObjToString().Equals(item.Value.ObjToString())))
|
|
{
|
|
throw new Exception(errorMessage);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|