Skip to content

ResetWorksAsExpected never compares the replayed bars #9699

Description

@mkzung

BaseConsolidatorTests.ResetWorksAsExpected collects the consolidated bars, resets, replays the same values and then compares the two lists:

Assert.AreEqual(consolidatedBarsBefore.Count, consolidatedBarsAfter.Count);
consolidatedBarsBefore.Zip<IBaseData, IBaseData, bool>(consolidatedBarsAfter, AssertConsolidatedValues);

Zip is lazy and the result is discarded, so AssertConsolidatedValues never runs. Only the counts are compared, across all 16 classes that inherit the fixture.

Putting Assert.Fail("the comparison ran") as the first line of AssertConsolidatedValues leaves all 17 tests passing.

What that misses, on master: deleting _workingBar = null; from PeriodCountConsolidatorBase.Reset() leaves a genuine state leak in the base class most consolidators derive from, and ResetWorksAsExpected still passes 17 of 17. The bar counts match because the leak changes bar contents, not how many close.

Three of the sixteen also produce no consolidated bars at all with the values the fixture feeds, so there is nothing to compare even once the comparison runs:

  • OpenInterestConsolidatorTests consolidates on TimeSpan.FromDays(1) and feeds 11 minutes
  • MarketHourAwareConsolidatorTests consolidates hourly and feeds 11 minutes
  • DataConsolidatorPythonWrapperTests uses a python consolidator that never sets consolidated, which is deliberate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions