Skip to content

Add WithShowStatsCommand with unit and integration tests #261

Description

@mpaulosky

Parent

Closes part of #258 — Refactor AppHost MongoDB Dev Commands into WithMongoDbDevCommands Extension

What to build

Extend MongoDbResourceBuilderExtensions with a WithShowStatsCommand helper (called internally by WithMongoDbDevCommands) that registers an Aspire dashboard command. When triggered, the command queries each collection in the target database for its document count and returns a Markdown table via CommandResultData with Format = Markdown and DisplayImmediately = true so the dialog auto-opens.

The table columns should be Collection and Document Count. When the database has no non-system collections, the Markdown output should contain a *(no collections found)* row and still return Success = true. The command skips system.* collections (consistent with clear-data). The command shares the existing SemaphoreSlim(1,1) — a concurrent read attempt during a clear or seed is non-blocking.

Acceptance criteria

  • WithShowStatsCommand private helper registered inside WithMongoDbDevCommands
  • Returns a Markdown table with columns Collection and Document Count for every non-system collection
  • CommandResultData.DisplayImmediately = true so the result dialog opens automatically
  • Empty database (or database with only system.* collections) returns *(no collections found)* row with Success = true
  • A concurrent invocation (semaphore held) returns CommandResults.Failure without throwing
  • Unit test verifies the command annotation is registered on the resource (name, display name, icon)
  • Integration test seeds ≥ 1 document, runs ShowStats, and asserts the Markdown output contains the collection name and a non-zero count
  • Integration test asserts the empty-DB case returns the *(no collections found)* row
  • All 10 existing tests (unit + integration) continue to pass

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgo:needs-researchNeeds investigationsquadSquad triage inbox — Lead will assign to a membersquad:samAssigned to Sam (Backend / .NET)type:featureNew capability

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions