refactor(dotnet): normalize formula service inputs
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 17s
Validators (Pushes and Pull Requests) / validate-core (push) Has been cancelled

This commit is contained in:
2026-07-13 01:28:05 +09:00
parent e745cfb0ae
commit cb814b8aa2
2 changed files with 77 additions and 12 deletions
@@ -0,0 +1,48 @@
using Moq;
using QuantEngine.Application.Services;
using QuantEngine.Core.Domain;
using QuantEngine.Core.Interfaces;
namespace QuantEngine.Core.Tests;
public class FormulaServiceTests
{
[Fact]
public async Task ComputeAndRecordFinalDecisionAsync_NormalizesInputs()
{
var historyStore = new Mock<IPostgresqlHistoryStore>(MockBehavior.Strict);
var learningStore = new Mock<INormalizedLearningStore>(MockBehavior.Strict);
learningStore.Setup(s => s.AppendDecisionAsync(It.IsAny<DecisionEventRecord>()))
.ReturnsAsync(Guid.NewGuid());
var service = new FormulaService(historyStore.Object, new DecisionLearningService(learningStore.Object));
var result = await service.ComputeAndRecordFinalDecisionAsync(
new Dictionary<string, object>
{
["entryModeGate"] = "PASS",
["entryMode"] = "PULLBACK",
["leaderGate"] = "PASS",
["acGate"] = "CLEAR",
["priceStatus"] = "PRICE_OK",
["atr20"] = 1.5
},
" decision-1 ",
" 005930 ",
" v1 ",
[]);
Assert.NotEqual(Guid.Empty, result);
learningStore.VerifyAll();
}
[Fact]
public async Task AppendFormulaRunAsync_RejectsBlankName()
{
var service = new FormulaService(new Mock<IPostgresqlHistoryStore>().Object, new DecisionLearningService(new Mock<INormalizedLearningStore>().Object));
await Assert.ThrowsAsync<ArgumentException>(() =>
service.AppendFormulaRunAsync(" ", new Dictionary<string, object?>()));
}
}