2019-11-22 10:48:53 +08:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using Falcon.ModelSP;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Falcon.ModelSP.Test.Db;
|
|
|
|
|
|
|
|
|
|
namespace Falcon.ModelSP.Test
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class ModelSPTest
|
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void getParamsTest() {
|
|
|
|
|
var model = new ParmModel { Id = 1,Name = "n1",AAAge = 10 };
|
|
|
|
|
|
|
|
|
|
var data = DataExtend.getParams(model);
|
|
|
|
|
Assert.IsNotNull(data);
|
|
|
|
|
Assert.IsTrue(data.Count() == typeof(ParmModel).GetProperties().Length - 1);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(data.Any(m => m.ParameterName == "@Id" && m.Value.Equals(1)));
|
|
|
|
|
Assert.IsTrue(data.Any(m => m.ParameterName == "@Name" && m.Value.Equals("n1")));
|
|
|
|
|
Assert.IsTrue(data.Any(m => m.ParameterName == "@age" && m.Value.Equals(10)));
|
|
|
|
|
Assert.IsTrue(!data.Any(m => m.ParameterName == "@Address"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void getProcuderNameTest() {
|
|
|
|
|
var model = new ParmModel { };
|
|
|
|
|
Assert.IsTrue(DataExtend.getProcuderName<ParmModel>() == "ParmModel");
|
|
|
|
|
Assert.IsTrue(DataExtend.getProcuderName<ParmModel1>() == "sp123");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ParmModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
[FalconSPPrarmName("age")]
|
|
|
|
|
public int AAAge { get; set; }
|
|
|
|
|
|
|
|
|
|
[FalconSPIgnore]
|
|
|
|
|
public string Address { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[FalconSPProcuderName("sp123")]
|
|
|
|
|
class ParmModel1 { }
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void InMemoryDbTest() {
|
|
|
|
|
//<2F>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ʹ<EFBFBD>ù<EFBFBD>ϵģ<CFB5>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return;
|
2020-11-20 14:59:21 +08:00
|
|
|
|
//using(var db = TestDbContext.GetDbInMemory()) {
|
|
|
|
|
// var re = db.Pr_AddOne(new Pr_AddOne { A = 1 });
|
|
|
|
|
// Assert.IsTrue(re != null);
|
|
|
|
|
// Assert.IsTrue(re.Any());
|
|
|
|
|
// var first = re.First();
|
|
|
|
|
// Assert.IsTrue(first.Aa == 2);
|
|
|
|
|
//}
|
2019-11-22 10:48:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|