Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 2.73 KB

File metadata and controls

42 lines (28 loc) · 2.73 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

Verify.Cosmos is a Verify extension that adds snapshot testing support for Azure Cosmos DB response types (Response<T>, FeedResponse<T>, Headers). It serializes Cosmos DB responses into a deterministic, diffable format by stripping volatile fields (ETags, diagnostics, x-ms-* headers, dates) and rounding request charges.

Build & Test Commands

All commands run from the src/ directory. The solution uses .NET SDK 10.0 (preview) with latestFeature roll-forward.

# Build
dotnet build src

# Run all tests (requires Cosmos DB Emulator running on https://localhost:8081)
dotnet test src/Tests

# Run a single test
dotnet test src/Tests --filter "FullyQualifiedName~Tests.ItemResponse"

Tests use xUnit v3 with Verify.XunitV3. They require the Azure Cosmos DB Emulator running locally — tests connect to https://localhost:8081 with the well-known emulator key.

Architecture

  • src/Verify.Cosmos/ — The NuGet library. Targets net8.0.

    • VerifyCosmos.cs — Entry point. Initialize() registers ignored members (ETag, CosmosDiagnostics, IndexingPolicy, etc.) and adds the custom JSON converters. Must be called once via [ModuleInitializer] before any Verify assertions.
    • Converters/ResponseConverter.cs — Handles Response<T>: serializes RequestCharge (rounded), Headers, StatusCode, Resource.
    • Converters/FeedResponseConverter.cs — Handles FeedResponse<T>: same as above plus Count. Uses CanConvert to walk the type hierarchy for generic type matching.
    • Converters/HeadersConverter.cs — Filters out x-ms-*, etag, date, and lsn headers from snapshots.
  • src/Tests/ — Integration tests against the Cosmos DB Emulator. Verified snapshots are *.verified.txt files adjacent to the test file.

Key Conventions

  • Central Package Management: Package versions are in src/Directory.Packages.props. Never add version attributes directly to PackageReference in .csproj files.
  • C# language version: preview (set in Directory.Build.props).
  • Code style: var everywhere, expression-bodied members, file-scoped namespaces, no explicit access modifiers. Enforced via .editorconfig.
  • Verify snapshots: *.verified.txt files use UTF-8 BOM, LF line endings, no final newline, and no indentation rules (configured in .editorconfig). Never hand-edit verified files — they are generated by running tests with Verify.
  • Strong naming: The library is strong-named (src/key.snk) with InternalsVisibleTo granting test access.