Merge branch 'glms/feature/0812_zmr_divPower' into 'glms/feature/1.4.2'
refactor(swap): 统一债券价格处理逻辑 See merge request otc-dev/zszq-trs!13
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace YLErp.Modules.EodModule
|
||||
{
|
||||
[TestClass]
|
||||
public class BondPaymentListQueryBoundaryTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void SearchList_OnlyQueriesBondPaymentTable()
|
||||
{
|
||||
var source = ReadBondPaymentServiceSource();
|
||||
var searchList = ExtractMethod(source, "public SearchListResult<BondPaymentDto> SearchList", "public BondPayment SaveBondPayment");
|
||||
|
||||
Assert.IsFalse(
|
||||
searchList.Contains("ex_dividend_info", StringComparison.Ordinal),
|
||||
"债券付息列表只能查询 bond_payment_info,不能把公司行为除权表拼入展示结果。");
|
||||
StringAssert.Contains(searchList, "DbContext.bondPayment");
|
||||
}
|
||||
|
||||
private static string ExtractMethod(string source, string startMarker, string endMarker)
|
||||
{
|
||||
var start = source.IndexOf(startMarker, StringComparison.Ordinal);
|
||||
Assert.IsTrue(start >= 0, $"Could not find method: {startMarker}");
|
||||
var end = source.IndexOf(endMarker, start + startMarker.Length, StringComparison.Ordinal);
|
||||
Assert.IsTrue(end >= 0, $"Could not find method end: {endMarker}");
|
||||
return source.Substring(start, end - start);
|
||||
}
|
||||
|
||||
private static string ReadBondPaymentServiceSource()
|
||||
{
|
||||
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
while (directory != null)
|
||||
{
|
||||
var path = Path.Combine(directory.FullName, "YLErpDAL", "Modules", "EodModule", "BondPaymentService.cs");
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
directory = directory.Parent;
|
||||
}
|
||||
|
||||
Assert.Fail("Could not locate BondPaymentService.cs from the test output directory.");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace YLErp.Modules.EodModule
|
||||
{
|
||||
[TestClass]
|
||||
public class DividendInfoEditGuardMessageTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void AddDividendInfos_ReportsTheReferencingTradeNumberWhenAnExecutedActionIsEdited()
|
||||
{
|
||||
var source = ReadDividendServiceSource();
|
||||
var addDividendInfos = ExtractMethod(source, "public bool AddDividendInfos", "public bool checkDividendInfoExecuteStatus");
|
||||
var controllerSource = ReadExDividendInfoControllerSource();
|
||||
var deleteDividend = ExtractMethod(controllerSource, "public JsonResult deleteDividend", "public JsonResult ImportDividendInfo");
|
||||
|
||||
Assert.IsTrue(addDividendInfos.Contains("不可修改,有交易【", StringComparison.Ordinal));
|
||||
Assert.IsTrue(addDividendInfos.Contains("使用了该条除权除息数据", StringComparison.Ordinal));
|
||||
Assert.IsTrue(deleteDividend.Contains("不可修改,有交易【", StringComparison.Ordinal));
|
||||
Assert.IsTrue(deleteDividend.Contains("使用了该条除权除息数据", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
private static string ExtractMethod(string source, string startMarker, string endMarker)
|
||||
{
|
||||
var start = source.IndexOf(startMarker, StringComparison.Ordinal);
|
||||
Assert.IsTrue(start >= 0, $"Could not find method: {startMarker}");
|
||||
var end = source.IndexOf(endMarker, start + startMarker.Length, StringComparison.Ordinal);
|
||||
Assert.IsTrue(end >= 0, $"Could not find method end: {endMarker}");
|
||||
return source.Substring(start, end - start);
|
||||
}
|
||||
|
||||
private static string ReadDividendServiceSource()
|
||||
{
|
||||
return ReadSource("YLErpDAL", "Modules", "TradeModule", "DealModule", "DividendService.cs");
|
||||
}
|
||||
|
||||
private static string ReadExDividendInfoControllerSource()
|
||||
{
|
||||
return ReadSource("YLErpWeb", "Controllers", "ex_dividend_infoController.cs");
|
||||
}
|
||||
|
||||
private static string ReadSource(params string[] relativePath)
|
||||
{
|
||||
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
while (directory != null)
|
||||
{
|
||||
var path = Path.Combine(new[] { directory.FullName }.Concat(relativePath).ToArray());
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
directory = directory.Parent;
|
||||
}
|
||||
|
||||
Assert.Fail("Could not locate DividendService.cs from the test output directory.");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,8 @@ namespace YLErp.Modules.SwapModule
|
||||
Assert.IsFalse(snapshot.Applied);
|
||||
|
||||
var reason = SwapEventService.BuildCorporateActionEventReason(snapshot);
|
||||
StringAssert.Contains(reason, "BeforeQuantity=1000");
|
||||
StringAssert.Contains(reason, "AfterQuantity=0");
|
||||
StringAssert.Contains(reason, "调整前:名义本金:100000 期初标的价格:100 持仓数量:1000");
|
||||
StringAssert.Contains(reason, "调整后:名义本金:0 期初标的价格:0 持仓数量:0");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
Reference in New Issue
Block a user