Skip to content

Commit 2eae661

Browse files
committed
Tests: assert stopping state reports the actual manager failure
When the history manager throws, the adapter emits both an ErrorMessage and a Stopping emulation state carrying that same exception, stamped with the stop date. Assert the stopping state error is the actual InvalidOperationException the manager raised rather than a generic OperationCanceledException, and rename the generator forwarding test to match what it verifies - a manager-yielded tick is forwarded.
1 parent fc1acc7 commit 2eae661

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Tests/HistoryMessageAdapterTests.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,12 @@ public async Task StartAsync_WhenManagerThrows_SendsErrorAndStoppingState()
601601

602602
// Should have EmulationStateMessage with Stopping state
603603
var stoppingState = outMessages.OfType<EmulationStateMessage>()
604-
.FirstOrDefault(m => m.State == ChannelStates.Stopping);
604+
.SingleOrDefault(m => m.State == ChannelStates.Stopping && m.Error != null);
605605

606606
stoppingState.AssertNotNull();
607+
// The stopping state must carry the actual failure cause, not a generic cancellation.
608+
(stoppingState.Error is InvalidOperationException).AssertTrue();
609+
stoppingState.LocalTime.AssertEqual(manager.StopDate);
607610

608611
// The thrown manager exception should surface as an ErrorMessage (the test name promises an error).
609612
var errorMsg = outMessages.OfType<ErrorMessage>().FirstOrDefault();
@@ -701,17 +704,13 @@ public async Task StartAsync_YieldsMessages_SendsThemViaNewOutMessage()
701704
#region Generator Data Tests (without history)
702705

703706
[TestMethod]
704-
public async Task StartAsync_WithGenerator_NoHistory_YieldsGeneratorData()
707+
public async Task StartAsync_ManagerYieldedTick_ForwardsData()
705708
{
706709
var secProvider = CreateSecurityProvider();
707710
var secId = CreateSecurityId();
708711

709-
// Create manager that simulates generator-only data (no storage)
710712
var manager = new TestHistoryMarketDataManager();
711-
var generator = new RandomWalkTradeGenerator(secId);
712-
manager.RegisterGenerator(secId, DataType.Ticks, generator, 1);
713713

714-
// Add simulated generator output
715714
var generatedTick = new ExecutionMessage
716715
{
717716
SecurityId = secId,

0 commit comments

Comments
 (0)