From 0183b86f18d9897ff9487e6d864898954397991d Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 22 Sep 2026 04:45:10 +0800 Subject: Add bond buy to holdings minimal vertical slice (3d-22) --- tests/FundLab.Web.Tests/BoundaryTests.fs | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'tests/FundLab.Web.Tests') diff --git a/tests/FundLab.Web.Tests/BoundaryTests.fs b/tests/FundLab.Web.Tests/BoundaryTests.fs index 25d7867..3a9ec61 100644 --- a/tests/FundLab.Web.Tests/BoundaryTests.fs +++ b/tests/FundLab.Web.Tests/BoundaryTests.fs @@ -657,6 +657,58 @@ module ConfirmationBoundaryTests = Assert.Equal("100", updated.stockPositions[0].quantity) Assert.False(updated.stockPositionsInFlight) + [] + let ``bond buy failure keeps no position and surfaces a message`` () = + let fundId = "3fa85f64-5717-4562-b3fc-2c963f66afa6" + + let model = + { init () with + token = "qa-token" + createdFund = Some(FundBoundaryTests.sampleFund fundId) + bondCode = "999999" + bondTradeQuantity = "10" + bondTradeInFlight = true + bondTradeSeq = 1 } + + let updated, _ = update (BondTradeFailed(1, fundId, "collector exited with code 2")) model + + Assert.Empty updated.bondPositions + Assert.Contains("买入失败", updated.bondTradeMessage |> Option.defaultValue "") + Assert.False(updated.bondTradeInFlight) + + [] + let ``bond positions read completion stores decoded rows`` () = + let fundId = "3fa85f64-5717-4562-b3fc-2c963f66afa6" + + let model = + { init () with + createdFund = Some(FundBoundaryTests.sampleFund fundId) + bondPositionsReadSeq = 1 + bondPositionsInFlight = true } + + let raw : RawBondPositions = + { + fundId = fundId + positions = + [| + { + instrumentCode = "110075" + bondName = box "南航转债" + quantity = "10" + costCash = "1063.68" + lastTradedAt = "2026-09-21T08:00:00Z" + } + |] + } + + let updated, _ = update (BondPositionsReadCompleted(1, fundId, raw)) model + + Assert.Equal(1, updated.bondPositions.Length) + Assert.Equal("110075", updated.bondPositions[0].instrumentCode) + Assert.Equal(Some "南航转债", updated.bondPositions[0].bondName) + Assert.Equal("10", updated.bondPositions[0].quantity) + Assert.False(updated.bondPositionsInFlight) + [] let ``order decode keeps decimal strings and decodes option fields`` () = let confirmed = Api.decodeOrder (sampleConfirmedRaw ()) -- cgit v1.2.3