Skip to content

Lazy Loading: Integration Tests #139

Closed
Closed

Description

@JeremyCaney

Unit tests already demonstrates that lazy loading works in isolation, but nothing yet demonstrates that it works a real web request: Routing, controller, view-model mapping, and response caching all working together. This adds a test that requests an actual page whose view renders lazily-loaded child pages, and confirms the child data shows up correctly in the response.

Tasks

  • Create a small seed dataset representing a page with lazily-loaded children (StubLazyLoadingTopicRepositoryBuilder)
  • Add a test view model with a Children collection and a matching view
    • New LazyContainerTopicViewModel in the Host's Models/,
    • New LazyContainer.cshtml in the Host's Views/LazyContainer/
    • Deliberately don't use a Body attribute for the proof; reading it doesn't reliably trigger the lazy fill, so a passing test could be a false negative
  • Add the integration test: Request the page, assert both children render, plus a "canary" assertion on the page's own title (new LazyLoadingPipelineTest, OnTopic.AspNetCore.Mvc.IntegrationTests)
  • (Optional) Add a fetch-count spy to independently confirm the data loaded exactly once (StubLazyLoadingTopicRepository.GetFetchCount())
  • Add the equivalent test for extended attribute (e.g., Body) content (dependent on Preload TopicPayload as part of MapAsync() #133)
  • Confirm the existing integration suite still passes unchanged

Activity

  1. added this to the OnTopic 6.0.0 milestone on Jul 26, 2026
  2. self-assigned this
    on Jul 26, 2026
  3. added theissue type on Jul 26, 2026
  4. added
    Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.
    Area: RepositoriesRelates to the `ITopicRepository` interface or one of its implementations.
    Type: ImprovementImproves the functionality or interface of an existing feature.
    on Jul 26, 2026
  5. JeremyCaney commented on Aug 7, 2026

    @JeremyCaney
    MemberAuthor
    • Create a small seed dataset representing a page with lazily-loaded children (StubLazyLoadingTopicRepositoryBuilder)
      • Introduced StubLazyLoadingTopicRepository (aa2c476)
      • Introduced StubLazyLoadingTopicRepositoryBuilder (198ae09)
    • Add a test view model with a Children collection and a matching view
      • Superseded, not built; replaced by unit-level coverage against the repository double
      • Established unit tests for lazy-loading repository (db8fbe8)
      • Migrate and improve unit tests tests (3338fed)
      • New LazyContainerTopicViewModel in the Host's Models/
        • Not built
      • New LazyContainer.cshtml in the Host's Views/LazyContainer/
        • Not built
      • Deliberately don't use a Body attribute for the proof; reading it doesn't reliably trigger the lazy fill, so a passing test could be a false negative
    • Add the integration test: Request the page, assert both children render, plus a "canary" assertion on the page's own title (new LazyLoadingPipelineTest, OnTopic.AspNetCore.Mvc.IntegrationTests)
      • Superseded, not built
      • Established unit tests for lazy-loading repository (db8fbe8)
      • Migrate and improve unit tests tests (3338fed)
    • (Optional) Add a fetch-count spy to independently confirm the data loaded exactly once (StubLazyLoadingTopicRepository.GetFetchCount())
      • Introduced StubLazyLoadingTopicRepository (aa2c476)
    • Add the equivalent test for extended attribute (e.g., Body) content (dependent on Preload TopicPayload as part of MapAsync() #133)
    • Confirm the existing integration suite still passes unchanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.Area: RepositoriesRelates to the `ITopicRepository` interface or one of its implementations.Priority: 1Severity 2: MajorStatus 2: ScheduledPlanned for an upcoming release.Type: ImprovementImproves the functionality or interface of an existing feature.

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions