Merge branch 'refs/heads/glms/feature/1.4.2' into glms/feature/dotnumber

This commit is contained in:
张名锐
2026-07-31 09:19:09 +08:00
40 changed files with 1899 additions and 287 deletions
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using YLErp.DBModels;
using YLErp.Modules.RiskEngine.Dto;
namespace YLErp.Modules.RiskEngine
{
[TestClass]
public class RiskRuleApplicationStatusDecoupleContractTest
{
private static readonly string[] AvailabilityPropertyNames =
{
"AssociatedRuleCount",
"EffectiveRuleCount",
"CanEnable",
"CanDisable",
"EnableButtonTooltip",
"DisableButtonTooltip"
};
[TestMethod]
public void DisableRuleResult_UsesDecoupledContract()
{
AssertProperty<DisableRuleResult>("RuleId", typeof(long));
AssertProperty<DisableRuleResult>("AffectedActiveAppCount", typeof(int));
Assert.IsNull(typeof(DisableRuleResult).GetProperty("CascadedApplicationIds"));
}
[TestMethod]
public void DeleteRuleResult_ReportsAffectedApplications()
{
AssertProperty<DeleteRuleResult>("RuleId", typeof(long));
AssertProperty<DeleteRuleResult>("AffectedActiveAppCount", typeof(int));
AssertProperty<DeleteRuleResult>("CausedNoAvailableRuleAppIds", typeof(List<long>));
}
[TestMethod]
public void ApplicationDtos_ExposeAvailabilityFields()
{
AssertAvailabilityProperties<RiskApplicationListItem>();
AssertAvailabilityProperties<RiskApplicationDetail>();
}
[TestMethod]
public void BatchOperationResult_ExposesDecoupledApplicationImpactFields()
{
AssertProperty<BatchOperationItemResult>("AffectedApplicationIds", typeof(List<long>));
AssertProperty<BatchOperationItemResult>("CausedNoAvailableRuleApplicationIds", typeof(List<long>));
AssertProperty<BatchOperationResult>("AffectedApplicationIds", typeof(List<long>));
AssertProperty<BatchOperationResult>("CausedNoAvailableRuleApplicationIds", typeof(List<long>));
}
[TestMethod]
public void VariableDeleteReferenceMessage_ListsDistinctSortedRuleIds()
{
var method = typeof(RiskRuleService).GetMethod(
"BuildVariableDeleteReferenceMessage", BindingFlags.NonPublic | BindingFlags.Static);
Assert.IsNotNull(method);
var rules = new List<glms_risk_rule>
{
new glms_risk_rule { id = 12 },
new glms_risk_rule { id = 10 },
new glms_risk_rule { id = 12 }
};
var message = (string)method.Invoke(null, new object[] { rules });
Assert.AreEqual("该变量被 2 个规则引用(规则ID:10、12),无法删除", message);
}
private static void AssertAvailabilityProperties<T>()
{
foreach (var propertyName in AvailabilityPropertyNames)
{
var expectedType = propertyName.EndsWith("Tooltip", StringComparison.Ordinal)
? typeof(string)
: propertyName.StartsWith("Can", StringComparison.Ordinal)
? typeof(bool)
: typeof(int);
AssertProperty<T>(propertyName, expectedType);
}
}
private static void AssertProperty<T>(string propertyName, Type expectedType)
{
var property = typeof(T).GetProperty(propertyName);
Assert.IsNotNull(property, $"{typeof(T).Name}.{propertyName} should exist.");
Assert.AreEqual(expectedType, property.PropertyType, $"{typeof(T).Name}.{propertyName} type mismatch.");
}
}
}
@@ -33,6 +33,19 @@ namespace YLErp.UnitTestProject.Modules.TradeModule.DocGenerateModule
blankTrade, CompanyEnum.));
}
[DataTestMethod]
[DataRow("GLMS-st0728-20260729-FICC-Q-210210IB", true, "GLMS-ST0728-20260729-FICC-Q-210210IB")]
[DataRow("GLMS-st0728-20260729-FICC-Q-210210IB", false, "GLMS-st0728-20260729-FICC-Q-210210IB")]
public void NormalizeTradeNumberCase_AppliesUpperTradeNumberConfiguration(
string tradeNumber,
bool upperTradeNumber,
string expected)
{
var actual = GuolianContractNoGenerator.NormalizeTradeNumberCase(tradeNumber, upperTradeNumber);
Assert.AreEqual(expected, actual);
}
[TestMethod]
public void BuildTradeNumber_ClientTrade_UsesNumericSequenceAndSanitizesUnderlyingCode()
{