从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
namespace YLErp.Modules.ClientModule
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientPositionServiceTest : UnitTestBase
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetAllPositions()
|
||||
{
|
||||
var list = new ClientPositionService(GetOptUser()).GetAllPositionsV1(new ClientPositionQueryModel
|
||||
{
|
||||
PageSize = 1000,
|
||||
ClientId = 1,
|
||||
ValueDate = new DateTime(2023, 1, 2)
|
||||
});
|
||||
|
||||
Assert.IsTrue(list.Any(n => n.BinaryOption.PayoffType == "CashOrNothing"));
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("{0}::{1}::{2}", item.TradeNumber, item.CurrentPrice,item.InitMargin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
|
||||
namespace YLErp.Modules.ClientModule
|
||||
{
|
||||
[TestClass]
|
||||
public class TestClientInfoQueryService
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGetZipFileOfClientFiles()
|
||||
{
|
||||
OtcAppContext.Initialize(s =>
|
||||
{
|
||||
var s2 = s.Trim('/').Replace("/", "\\");
|
||||
return @"d:\\" + s2;
|
||||
});
|
||||
|
||||
var req = new ClientInfoQueryModel
|
||||
{
|
||||
ClientNumber = "ZQZ0094"
|
||||
};
|
||||
|
||||
var buf1 = new ClientInfoQueryService(OptUserInfo.SystemUser).GetZipFileOfClientFiles(req);
|
||||
|
||||
File.WriteAllBytes(@"D:\temp\unittest\clientfile1.zip", buf1);
|
||||
|
||||
using (var mstream = File.Open(@"D:\temp\unittest\clientfile1.zip", FileMode.Open))
|
||||
using (var s = new ZipInputStream(mstream))
|
||||
{
|
||||
ZipEntry theEntry;
|
||||
|
||||
var count = 0;
|
||||
|
||||
while ((theEntry = s.GetNextEntry()) != null)
|
||||
{
|
||||
count++;
|
||||
var fileName = Path.GetFileName(theEntry.Name);
|
||||
|
||||
if (fileName == string.Empty)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
using var streamWriter = File.Create(@"D:\temp\unittest\" + theEntry.Name);
|
||||
var size = 2048;
|
||||
var data = new byte[2048];
|
||||
while (true)
|
||||
{
|
||||
size = s.Read(data, 0, data.Length);
|
||||
if (size > 0)
|
||||
{
|
||||
streamWriter.Write(data, 0, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.AreEqual("", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,516 @@
|
||||
using YieldChain.Helpers;
|
||||
|
||||
namespace YLErp.Modules.ClientModule
|
||||
{
|
||||
[TestClass]
|
||||
public class TestClientUpdateApiService
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestDynamicUpdate()
|
||||
{
|
||||
var dic1 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" },
|
||||
{nameof(Client.Name), "吉祥如意科技有限公司" },
|
||||
{nameof(Client.Abbreviation), "大吉大利" },
|
||||
{nameof(Client.ClientType), "机构" }, //客户类别
|
||||
{nameof(Client.LicenseType), "营业执照" }, //证照类型
|
||||
{nameof(Client.LicenseCode), "0123456789012345" }, //证照编号
|
||||
{nameof(Client.AcceptableLoss), "20%~50%" },
|
||||
{nameof(Client.AccessRule), 1 },
|
||||
{nameof(Client.ActualController), "真真" },
|
||||
{nameof(Client.Address), "好地方" },
|
||||
{nameof(Client.EvaluateDate), "2022-02-02" },
|
||||
{nameof(Client.FundThreshold), 100.11 },
|
||||
{nameof(Client.IsListed), 1 }, //因为表字段类型是tinyint(1)即使填2也会返回1,看来默认把tinyint(1)当成了boolean处理
|
||||
{nameof(Client.MinimumTransferAmount), 202.22 },
|
||||
{nameof(Client.RightProtocolSignDate), new DateTime(2022, 2, 3) },
|
||||
{nameof(Client.MetaDic), new Dictionary<string,string>
|
||||
{
|
||||
{"opentime","2022-01-01" }
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
var service = new ClientSaveApiV2Service(OptUserInfo.SystemUser);
|
||||
|
||||
try
|
||||
{
|
||||
service.Save(dic1);
|
||||
}
|
||||
catch (ServiceException se)
|
||||
{
|
||||
Console.WriteLine(se.Message);
|
||||
Assert.IsTrue(se.Message.Contains("要更新的客户信息不存在"));
|
||||
}
|
||||
|
||||
dic1["_action"] = "updateOrCreate";
|
||||
|
||||
var result = service.Save(dic1);
|
||||
|
||||
CheckClient(result.ClientId, dic1);
|
||||
|
||||
//测试update
|
||||
|
||||
var dic2 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" }
|
||||
};
|
||||
|
||||
//update
|
||||
result = service.Save(dic2);
|
||||
|
||||
dic2[nameof(Client.Abbreviation)] = "吉祥如意";
|
||||
dic2[nameof(Client.InvestmentExperience)] = "基本";
|
||||
dic2[nameof(Client.LevelId)] = "0";
|
||||
dic2[nameof(Client.FundsSource)] = "1";
|
||||
dic2[nameof(Client.InvestmentTerm)] = "1";
|
||||
dic2[nameof(Client.RiskPreference)] = "1"; //一般
|
||||
dic2[nameof(Client.IsRealControl)] = "1";
|
||||
dic2[nameof(Client.TradingInstType)] = "1";
|
||||
dic2[nameof(Client.IsTradeCredit)] = "1";
|
||||
dic2[nameof(Client.IsEvaluate)] = "1";
|
||||
dic2[nameof(Client.RiskServiceDegree)] = "1";
|
||||
dic2[nameof(Client.MetaDic)] = new Dictionary<string, string> {
|
||||
{"OverstepPurchase","1" }
|
||||
};
|
||||
|
||||
//update
|
||||
result = service.Save(dic2);
|
||||
CheckClient(result.ClientId, MergeDictionary(dic1, dic2));
|
||||
|
||||
dic2[nameof(Client.TradingInstType)] = "";
|
||||
dic2[nameof(Client.MetaDic)] = null;
|
||||
|
||||
//update
|
||||
result = service.Save(dic2);
|
||||
CheckClient(result.ClientId, MergeDictionary(dic1, dic2));
|
||||
|
||||
//update
|
||||
try
|
||||
{
|
||||
var ddd = new Dictionary<string, object>
|
||||
{
|
||||
[nameof(Client.Number)] = "a001",
|
||||
[nameof(Client.LevelId)] = "0a",
|
||||
[nameof(Client.FundsSource)] = "1a",
|
||||
[nameof(Client.InvestmentTerm)] = "1a"
|
||||
};
|
||||
result = service.Save(ddd);
|
||||
Assert.Fail("未预期执行到这里");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.IsTrue(ex.Message.Contains(nameof(Client.LevelId)));
|
||||
}
|
||||
|
||||
//测试update
|
||||
|
||||
var dicDuties1 = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" },
|
||||
{"ContactType","联系人" },
|
||||
{nameof(ClientDuty.ContactName),"张三" },
|
||||
{nameof(ClientDuty.PhoneNumber),"18801230123" },
|
||||
{nameof(ClientDuty.Email),"zhangsan@yiliantech.com" },
|
||||
{nameof(ClientDuty.IsReceiveEmail),"1" },
|
||||
{nameof(ClientDuty.Fax),"zhangsan@fax" },
|
||||
{nameof(ClientDuty.IdCardType),"身份证" },
|
||||
{nameof(ClientDuty.IdCardDate),"" },
|
||||
{nameof(ClientDuty.IdCardNo),"322087199010214758" },
|
||||
{nameof(ClientDuty.Address),"北京西直门" },
|
||||
{nameof(ClientDuty.DeadLine),"2025-02-02" },
|
||||
{nameof(ClientDuty.AuthorizeEndDate),"2025-02-02" },
|
||||
{nameof(ClientDuty.Weixin),"hello_aaa" },
|
||||
{nameof(ClientDuty.Remarks),"张三在北京欢迎你" }
|
||||
},
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" },
|
||||
{"ContactType","联系人" },
|
||||
{nameof(ClientDuty.ContactName),"李四" },
|
||||
{nameof(ClientDuty.PhoneNumber),"188045674567" },
|
||||
{nameof(ClientDuty.Email),"lis@yiliantech.com" },
|
||||
{nameof(ClientDuty.IsReceiveEmail),"" },
|
||||
{nameof(ClientDuty.Fax),"lis@fax" },
|
||||
{nameof(ClientDuty.IdCardType),"身份证" },
|
||||
{nameof(ClientDuty.IdCardDate),"" },
|
||||
{nameof(ClientDuty.IdCardNo),"322087199909030202" },
|
||||
{nameof(ClientDuty.Address),"上海南京西路" },
|
||||
{nameof(ClientDuty.DeadLine),"2025-12-02" },
|
||||
{nameof(ClientDuty.AuthorizeEndDate),"2025-12-02" },
|
||||
{nameof(ClientDuty.Weixin),"lis_hahaha" },
|
||||
{nameof(ClientDuty.Remarks),"李四在此" }
|
||||
},
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" },
|
||||
{"ContactType","法人" },
|
||||
{nameof(ClientDuty.ContactName),"王五" },
|
||||
{nameof(ClientDuty.PhoneNumber),"" },
|
||||
{nameof(ClientDuty.Email),"" },
|
||||
{nameof(ClientDuty.IsReceiveEmail),"" },
|
||||
{nameof(ClientDuty.Fax),"" },
|
||||
{nameof(ClientDuty.IdCardType),"军官证" },
|
||||
{nameof(ClientDuty.IdCardDate),"" },
|
||||
{nameof(ClientDuty.IdCardNo),"JG-HA-001" },
|
||||
{nameof(ClientDuty.Address),"" },
|
||||
{nameof(ClientDuty.DeadLine),"" },
|
||||
{nameof(ClientDuty.AuthorizeEndDate),"" },
|
||||
{nameof(ClientDuty.Weixin),"" },
|
||||
{nameof(ClientDuty.Remarks),"" }
|
||||
}
|
||||
};
|
||||
|
||||
var dic3 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" },{"duties",dicDuties1 }
|
||||
};
|
||||
|
||||
//update
|
||||
result = service.Save(dic3);
|
||||
CheckClient(result.ClientId, MergeDictionary(dic1, dic2, dic3));
|
||||
CheckClientDuty(result.ClientId, dicDuties1);
|
||||
|
||||
try
|
||||
{
|
||||
dicDuties1 = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" }, {nameof(ClientDuty.IdCardNo),"JG-HA-001" }
|
||||
}
|
||||
};
|
||||
dic3 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" },{"duties",dicDuties1 }
|
||||
};
|
||||
result = service.Save(dic3);
|
||||
Assert.Fail("未预期执行到这里");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.IsTrue(ex.Message.Contains("与已有客户人员的证件编号重复"));
|
||||
}
|
||||
|
||||
//测试update
|
||||
|
||||
dicDuties1 = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","delete" },
|
||||
{nameof(ClientDuty.IdCardNo),"322087199010214758" }
|
||||
},
|
||||
new Dictionary<string, object> {
|
||||
{"_action","update" },
|
||||
{"ContactType","联系人" },
|
||||
{nameof(ClientDuty.ContactName),"王五" },
|
||||
{nameof(ClientDuty.Email),"wangwu@yiliantech.com" },
|
||||
{nameof(ClientDuty.IsReceiveEmail),"1" },
|
||||
{nameof(ClientDuty.IdCardNo),"JG-HA-001" }
|
||||
}
|
||||
};
|
||||
|
||||
var dicBankcards = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" },
|
||||
{nameof(ClientBankCard.Card),"62205566668888" },
|
||||
{nameof(ClientBankCard.Bank),"中国银行" },
|
||||
{nameof(ClientBankCard.Use),"转账1" },
|
||||
{nameof(ClientBankCard.State),"状态1" },
|
||||
{nameof(ClientBankCard.Comments),"备注1" },
|
||||
{nameof(ClientBankCard.Payment),"大额行号1" }
|
||||
},
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" },
|
||||
{nameof(ClientBankCard.Card),"62205577778888" },
|
||||
{nameof(ClientBankCard.Bank),"农业银行" },
|
||||
{nameof(ClientBankCard.Use),"转账2" },
|
||||
{nameof(ClientBankCard.State),"状态2" },
|
||||
{nameof(ClientBankCard.Comments),"备注2" },
|
||||
{nameof(ClientBankCard.Payment),"大额行号2" }
|
||||
},
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" },
|
||||
{nameof(ClientBankCard.Card),"62205599998888" },
|
||||
{nameof(ClientBankCard.Bank),"工商银行" },
|
||||
{nameof(ClientBankCard.Use),"转账3" }
|
||||
}
|
||||
};
|
||||
|
||||
var dicFiles1 = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{nameof(client_file.FileName),"111aaa.pdf" },
|
||||
{nameof(client_file.FileTypeName),"其他" },
|
||||
{nameof(client_file.FileDesc),"测试1" },
|
||||
},
|
||||
new Dictionary<string, object> {
|
||||
{nameof(client_file.FileName),"222aaa.pdf" },
|
||||
{nameof(client_file.FileTypeName),"其他" },
|
||||
{nameof(client_file.FileDesc),"测试2" },
|
||||
}
|
||||
};
|
||||
var pdfPath = Path.Combine(AppContext.BaseDirectory, "Resources\\a.pdf");
|
||||
dicFiles1[0]["FileContent"] = Convert.ToBase64String(File.ReadAllBytes(pdfPath));
|
||||
dicFiles1[1]["FileContent"] = dicFiles1[0]["FileContent"];
|
||||
var dic4 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" },
|
||||
{"duties",dicDuties1 },
|
||||
{"bankcards",dicBankcards },
|
||||
{"files",dicFiles1 },
|
||||
};
|
||||
|
||||
//update
|
||||
result = service.Save(dic4);
|
||||
CheckClientDuty(result.ClientId, dicDuties1);
|
||||
CheckClientBankCard(result.ClientId, dicBankcards);
|
||||
|
||||
dicDuties1 = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","delete" },
|
||||
{nameof(ClientDuty.IdCardNo),"322087199010214758" }
|
||||
}
|
||||
};
|
||||
dic4 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" },
|
||||
{"duties",dicDuties1 }
|
||||
};
|
||||
result = service.Save(dic4);
|
||||
Assert.IsTrue(result.DutyResults.First().ResultMessage.Contains("要删除的客户人员信息不存在"));
|
||||
|
||||
try
|
||||
{
|
||||
dicBankcards = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" },
|
||||
{nameof(ClientBankCard.Card),"62205566668888" },
|
||||
{nameof(ClientBankCard.Bank),"中国银行" },
|
||||
{nameof(ClientBankCard.Use),"转账1" },
|
||||
{nameof(ClientBankCard.State),"状态1" },
|
||||
{nameof(ClientBankCard.Comments),"备注1" },
|
||||
{nameof(ClientBankCard.Payment),"大额行号1" }
|
||||
}
|
||||
};
|
||||
dic4 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" },
|
||||
{"bankcards",dicBankcards }
|
||||
};
|
||||
result = service.Save(dic4);
|
||||
Assert.Fail("未预期执行到这里");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Assert.IsTrue(ex.Message.Contains("与已有客户银行卡的银行账号重复"));
|
||||
}
|
||||
|
||||
dicDuties1 = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","update" },
|
||||
{"ContactType","联系人" },
|
||||
{nameof(ClientDuty.ContactName),"王五" },
|
||||
{nameof(ClientDuty.Email),"wangwu@yiliantech.com" },
|
||||
{nameof(ClientDuty.IsReceiveEmail),"1" },
|
||||
{nameof(ClientDuty.IdCardNo),"JG-HA-001" }
|
||||
}
|
||||
};
|
||||
dicBankcards = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","updateOrCreate" },
|
||||
{nameof(ClientBankCard.Card),"62205566668888" },
|
||||
{nameof(ClientBankCard.State),"状态1111" },
|
||||
{nameof(ClientBankCard.Comments),"备注1111" },
|
||||
{nameof(ClientBankCard.Payment),"大额行号111" }
|
||||
},
|
||||
new Dictionary<string, object> {
|
||||
{"_action","delete" },
|
||||
{nameof(ClientBankCard.Card),"62205577778888" },
|
||||
{nameof(ClientBankCard.Bank),"农业银行" },
|
||||
},
|
||||
new Dictionary<string, object> {
|
||||
{"_action","update" },
|
||||
{nameof(ClientBankCard.Card),"62205599998888" },
|
||||
{nameof(ClientBankCard.Bank),"工商银行" },
|
||||
{nameof(ClientBankCard.Use),"转账3333" }
|
||||
}
|
||||
};
|
||||
dicFiles1 = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","delete" },
|
||||
{nameof(client_file.FileName),"111aaa.pdf" }
|
||||
}
|
||||
};
|
||||
dic4 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" },
|
||||
{"duties",dicDuties1 },
|
||||
{"bankcards",dicBankcards },
|
||||
{"files",dicFiles1 },
|
||||
};
|
||||
result = service.Save(dic4);
|
||||
CheckClientDuty(result.ClientId, dicDuties1);
|
||||
CheckClientBankCard(result.ClientId, dicBankcards);
|
||||
|
||||
try
|
||||
{
|
||||
dicBankcards = new[] {
|
||||
new Dictionary<string, object> {
|
||||
{"_action","create" }, {nameof(ClientBankCard.Card),"62205599998888" }
|
||||
}
|
||||
};
|
||||
dic3 = new Dictionary<string, object> {
|
||||
{nameof(Client.Number), "a001" },{"bankcards",dicBankcards }
|
||||
};
|
||||
result = service.Save(dic3);
|
||||
Assert.Fail("未预期执行到这里");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.IsTrue(ex.Message.Contains("与已有客户银行卡的银行账号重复"));
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckClient(int clientId, Dictionary<string, object> dic)
|
||||
{
|
||||
var db = DbContextFactory.GetClientDbContext(OptUserInfo.SystemUser);
|
||||
var dbClient = db.client.FirstOrDefault(n => n.id == clientId);
|
||||
|
||||
foreach (var k in dic.Keys)
|
||||
{
|
||||
if (k == nameof(Client.MetaDic) || k == "_action" || k == "duties" || k == "bankcards")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var prop = dbClient.GetType().GetProperty(k);
|
||||
var dbVal = prop.GetValue(dbClient);
|
||||
|
||||
Assert.IsTrue(InnerCompare(dic[k], dbVal, prop.PropertyType), k);
|
||||
}
|
||||
var dbClientMetas = db.ClientMeta.Where(n => n.ClientId == clientId).ToArray();
|
||||
var meta = dbClientMetas.FirstOrDefault(n => n.MetaKey == "opentime");
|
||||
Assert.IsTrue(meta != null && meta.MetaValue == "2022-01-01", "meta.opentime");
|
||||
}
|
||||
|
||||
static bool InnerCompare(object dicVal, object dbVal, Type dbValType)
|
||||
{
|
||||
dicVal = YLMapperHelper.TypeConvert(dicVal, dbValType, out _);
|
||||
|
||||
if (dicVal == null)
|
||||
{
|
||||
return dbVal == null;
|
||||
}
|
||||
|
||||
return dicVal.Equals(dbVal);
|
||||
}
|
||||
|
||||
private void CheckClientDuty(int clientId, Dictionary<string, object>[] dics)
|
||||
{
|
||||
var db = DbContextFactory.GetClientDbContext(OptUserInfo.SystemUser);
|
||||
var clientdutyList = db.clientduty.Where(n => n.ApprovalOrder < 1 && n.ClientId == clientId).ToArray();
|
||||
foreach (var dicOri in dics)
|
||||
{
|
||||
var dic = new Dictionary<string, object>(dicOri, StringComparer.OrdinalIgnoreCase);
|
||||
dic.TryGetValue("_action", out var obj_action);
|
||||
var action = obj_action?.ToString() ?? "update";
|
||||
dic.TryGetValue(nameof(ClientDuty.IdCardNo), out var obj_idCardNo);
|
||||
var cardNo = obj_idCardNo.ToString();
|
||||
if (action == "delete")
|
||||
{
|
||||
Assert.IsTrue(!clientdutyList.Any(n => n.IdCardNo == cardNo));
|
||||
}
|
||||
else
|
||||
{
|
||||
var duty = clientdutyList.FirstOrDefault(n => n.IdCardNo == cardNo);
|
||||
Assert.IsNotNull(duty);
|
||||
foreach (var k in dic.Keys)
|
||||
{
|
||||
if (k == nameof(Client.MetaDic) || k == "_action"
|
||||
|| k == nameof(ClientDuty.ContactType) || k == nameof(ClientDuty.IdCardType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var prop = duty.GetType().GetProperty(k);
|
||||
var dbVal = prop.GetValue(duty);
|
||||
|
||||
Assert.IsTrue(InnerCompare(dic[k], dbVal, prop.PropertyType), k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckClientBankCard(int clientId, Dictionary<string, object>[] dics)
|
||||
{
|
||||
var db = DbContextFactory.GetClientDbContext(OptUserInfo.SystemUser);
|
||||
var bankcardList = db.bankcard.Where(n => n.ApprovalOrder < 1 && n.ClientId == clientId).ToArray();
|
||||
foreach (var dicOri in dics)
|
||||
{
|
||||
var dic = new Dictionary<string, object>(dicOri, StringComparer.OrdinalIgnoreCase);
|
||||
dic.TryGetValue("_action", out var obj_action);
|
||||
var action = obj_action?.ToString() ?? "update";
|
||||
dic.TryGetValue(nameof(ClientBankCard.Card), out var obj_cardNo);
|
||||
var cardNo = obj_cardNo.ToString();
|
||||
if (action == "delete")
|
||||
{
|
||||
var del = bankcardList.FirstOrDefault(n => n.Card == cardNo);
|
||||
Assert.IsTrue(del.ValidState == "InValid");
|
||||
}
|
||||
else
|
||||
{
|
||||
var duty = bankcardList.FirstOrDefault(n => n.Card == cardNo);
|
||||
Assert.IsNotNull(duty);
|
||||
foreach (var k in dic.Keys)
|
||||
{
|
||||
if (k == nameof(Client.MetaDic) || k == "_action")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var prop = duty.GetType().GetProperty(k);
|
||||
var dbVal = prop.GetValue(duty);
|
||||
|
||||
Assert.IsTrue(InnerCompare(dic[k], dbVal, prop.PropertyType), k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, object> MergeDictionary(params Dictionary<string, object>[] dics)
|
||||
{
|
||||
Dictionary<string, object> dic = null;
|
||||
|
||||
foreach (var d in dics)
|
||||
{
|
||||
if (d == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dic == null)
|
||||
{
|
||||
dic = new Dictionary<string, object>(d, d.Comparer);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var k in d.Keys)
|
||||
{
|
||||
dic[k] = d[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dic;
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void Cleanup()
|
||||
{
|
||||
var db = DbContextFactory.GetClientDbContext(OptUserInfo.SystemUser);
|
||||
var aa = db.client.FirstOrDefault(n => n.Number == "a001");
|
||||
if (aa != null)
|
||||
{
|
||||
db.client.Remove(aa);
|
||||
db.BulkDelete<ClientMeta>(nameof(ClientMeta.ClientId) + "=" + aa.id);
|
||||
db.BulkDelete<ClientDuty>(nameof(ClientDuty.ClientId) + "=" + aa.id);
|
||||
db.BulkDelete<ClientBankCard>(nameof(ClientBankCard.ClientId) + "=" + aa.id);
|
||||
db.BulkDelete<client_file>(nameof(client_file.ClientId) + "=" + aa.id);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user