diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-22 04:45:10 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-22 04:45:10 +0800 |
| commit | 0183b86f18d9897ff9487e6d864898954397991d (patch) | |
| tree | 245c8f197f5803802dd630f278e9f2a08affa4ec /tests/FundLab.Web.Tests/BoundaryTests.fs | |
| parent | b6008d67232756d743699472865025159f6ec533 (diff) | |
| download | fund-lab-0183b86f18d9897ff9487e6d864898954397991d.tar.gz | |
Add bond buy to holdings minimal vertical slice (3d-22)
Diffstat (limited to 'tests/FundLab.Web.Tests/BoundaryTests.fs')
| -rw-r--r-- | tests/FundLab.Web.Tests/BoundaryTests.fs | 52 |
1 files changed, 52 insertions, 0 deletions
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 @@ -658,6 +658,58 @@ module ConfirmationBoundaryTests = Assert.False(updated.stockPositionsInFlight) [<Fact>] + 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) + + [<Fact>] + 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) + + [<Fact>] let ``order decode keeps decimal strings and decodes option fields`` () = let confirmed = Api.decodeOrder (sampleConfirmedRaw ()) let pending = Api.decodeOrder (samplePendingRaw ()) |
