refactor(dotnet): normalize formula service inputs
This commit is contained in:
@@ -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?>()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user