mongo-csharp-driver / MongoDB.Driver.TestHelpers
AGENTS.md3.2k starsChanged 4 months agoApache-2.0View on GitHub
Shared test infrastructure for the driver test projects. Hosts integration-test base classes, fixtures, mock implementations, fail-point helpers, event capture, and xUnit extensions. Sibling helper projects: tests/MongoDB.Bson.TestHelpers/ (BSON-specific) and tests/MongoDB.TestHelpers/ (cross-cutting xUnit). Under Core/JsonDrivenTests/: a small set of event asserters and field-setter helpers (CommandStartedEventAsserter, EventAsserterFactory, RecursiveFieldSetter) used by the spec runners in tests/MongoDB.Driver.Tests/Specifications/. The broader JSON-driven test base classes (test factories, document/value comparers, JSON resource loading) live in the sibling project at tests/MongoDB.Bson.TestHelpers/JsonDrivenTests/, not here.
Trending
Quiet since September.about the whole repository
Who's talking about mongodb/mongo-csharp-driver
- jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources“Support for latest MongoDB library with signing”GitHub · Jul 28, 2024 · 13 reactions
- opensearch-project/opensearch-net“[FEATURE] Add LINQ Support to the OpenSearch C# Client”GitHub · Sep 18, 2023 · 5 reactions
- nopSolutions/nopCommerce“MongoDB database support”GitHub · Apr 30, 2019 · 4 reactions
- microsoft/aspire“MongoDB.Driver v3 breaks Aspire.MongoDB.Driver integration”GitHub · Oct 18, 2024 · 3 reactions
- jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources“Deprecate this package”GitHub · Apr 21, 2026 · 2 reactions
The biggest 5 of 40 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 40
Talked about on GitHub (40 times).
On GitHub · 40
- Jul 28, 2024Support for latest MongoDB library with signing — jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources13 reactions · 5 comments
- Sep 18, 2023[FEATURE] Add LINQ Support to the OpenSearch C# Client — opensearch-project/opensearch-net5 reactions · 1 comment
- Apr 30, 2019MongoDB database support — nopSolutions/nopCommerce4 reactions · 24 comments
- Oct 18, 2024MongoDB.Driver v3 breaks Aspire.MongoDB.Driver integration — microsoft/aspire3 reactions · 9 comments
- Apr 21, 2026Deprecate this package — jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources2 reactions · 1 comment
35 more on GitHub
- Nov 5, 2025Corrected Membership Session Handling — OrleansContrib/Orleans.Providers.MongoDB2 reactions · 2 comments
- Jun 4, 2016Support .NET Core — tugberkugurlu/AspNetCore.Identity.MongoDB2 reactions · 1 comment
- Jul 12, 2026Upgrade MongoDB.Driver to 3.9.0 to fix Snappier and SharpCompress vulnerabilities — madelson/DistributedLock1 reaction
- May 28, 2026Upgrade MongoDB.Driver to 3.9.0 — abpframework/abp1 reaction · 1 comment
- May 12, 2026Upgrade MongoDB.Driver to 3.8.1 — abpframework/abp1 reaction
- Mar 19, 2026bump MongoDB.Driver to 3.7.1 — abpframework/abp1 reaction
- Jan 18, 2026Update MongoDB.Driver package version to 3.6.0 — abpframework/abp1 reaction · 1 comment
- Nov 20, 2025Update MongoDB.Driver to version 3.5.1 — abpframework/abp1 reaction
- Jan 30, 2023Hangfire.Mongo is incompatible with the MongoDB.Driver LINQ3 provider — gottscj/Hangfire.Mongo1 reaction · 1 comment
- Jun 6, 2022Mongo Driver Compatibility — alirezanet/Gridify1 reaction · 3 comments
- Mar 31, 2015Support for 2.0 async driver — RobThree/MongoRepository1 reaction · 35 comments
- Sep 29, 2026Bump MongoDB.Driver from 2.11.5 to 2.19.0 — ramonaoldf/run-devops0 reactions
- Sep 15, 2026Bump the nuget group with 1 update — ApurvSinghal/ApurvXam0 reactions
- Aug 2, 2026Bump MongoDB.Driver from 2.8.1 to 2.19.0 — mohaom/TailwindTraders-Website0 reactions
- Jan 12, 2025Bump MongoDB.Driver from 2.14.1 to 2.19.0 in /src/Infrastructure — vigovlugt/LeagueOfItemsBackend0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.19.0 [SECURITY] — MrDariusAD/DynamicFilter0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.12.2 [SECURITY] — ShamKarthikS-Hexaware/recicd0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.12.2 [SECURITY] — MrDariusAD/GirlfriendAdventskalender0 reactions
- Jan 15, 2024Bump MongoDB.Driver.Core and MongoDB.Bson — kravvya/GardenLog.V20230 reactions
- Nov 17, 2023build(deps): bump MongoDb_Version from 2.19.0 to 2.22.0 — AntonioFalcaoJr/EventualShop0 reactions
- Mar 28, 2023Bump MongoDB.Driver from 2.19.0 to 2.19.1 — eincioch/dotnet-microservices-boilerplate0 reactions
- Mar 27, 2023Bump MongoDB.Driver from 2.19.0 to 2.19.1 — niaz-ali-khan/microservise0 reactions
- Mar 3, 2023Bump MongoDB.Driver from 2.13.1 to 2.19.0 in /DotNet/POC/DatabaseBenchmark — AdamNagy/Nadam.Tryouts0 reactions
- Mar 3, 2023Bump MongoDB.Driver from 2.12.3 to 2.19.0 in /Esiur.Stores.MongoDB — esiur/esiur-dotnet0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.17.1 to 2.18.0 in /src/backend — ScottishTapWater/OrderBook0 reactions
- Oct 17, 2022fix(deps): bump MongoDB.Driver from 2.16.1 to 2.18.0 — Manu0912/doppler-push-contact0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.13.0 to 2.18.0 — uruk-project/uruk-server0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.15.1 to 2.18.0 — joelbyford/ApiPatternsClient0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.13.1 to 2.18.0 in /examples/AspNetCoreMvc — brucehu123/opentelemetry-dotnet-instrumentation0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/common/Platform.Common — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/lobby/Platform.Lobby.Tests — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/eucre-game/Games.Eucre.Api — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/weather/Weather.Api — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/library/Platform.Library.Api — frogsbreath-games/eucre0 reactions
- May 24, 2022Bump MongoDB.Driver from 2.13.1 to 2.15.1 in /examples/AspNetCoreMvc — brucehu123/opentelemetry-dotnet-instrumentation0 reactions
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- src/MongoDB.Bson/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Authentication/AGENTS.mdAGENTS.md
- src/MongoDB.Driver.Authentication.AWS/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Bindings/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Events/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Logging/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Operations/AGENTS.mdAGENTS.md
- src/MongoDB.Driver.Encryption/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Encryption/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/GeoJsonObjectModel/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/GridFS/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Linq/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Search/AGENTS.mdAGENTS.md
- tests/MongoDB.Driver.Tests/Specifications/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- src/MongoDB.Bson/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver.Authentication.AWS/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Authentication/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Bindings/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Events/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Logging/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Operations/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver.Encryption/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Encryption/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/GeoJsonObjectModel/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/GridFS/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Linq/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Search/CLAUDE.mdCLAUDE.md
- tests/MongoDB.Driver.TestHelpers/CLAUDE.mdCLAUDE.md
- tests/MongoDB.Driver.Tests/Specifications/CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 53
Leaked fail-points: Always using. If a test asserts mid-fail-point and the assertion throws, Dispose runs.
- Distinctive: line 68
When changing helpers in a way that affects skip behavior, scan the test logs for unexpected skips before declaring done.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MongoDB.Driver.TestHelpers — AGENTS.md
Shared test infrastructure for the driver test projects. Hosts integration-test base classes, fixtures, mock implementations, fail-point helpers, event capture, and xUnit extensions. Sibling helper projects: tests/MongoDB.Bson.TestHelpers/ (BSON-specific) and tests/MongoDB.TestHelpers/ (cross-cutting xUnit).
Core fixtures and bases
IntegrationTest<TFixture>— base for tests that require a live MongoDB. The constructor's signature isIntegrationTest(TFixture fixture, Action<RequireServer> requireServerCheck = null): if the test passes a callback, the constructor callsRequireServer.Check()and invokes the callback with the resultingRequireServerinstance, so the callback can chain fluent skip assertions on it (e.g.requireServer.VersionGreaterThanOrEqualTo("7.0").Authentication(true)). If no callback is passed, no skip check is performed by the base. TheBeforeTestCase()call is unconditional — gated only by whether the test passes a fixture instance, not by whether therequireServerCheckcallback is supplied; the callback only gates the optional skip check.MongoDatabaseFixture— lazy-creates a per-class temporary database (CSTests<timestamp>); tracks created collections and drops them onDispose.BeforeTestCase()is the orchestrator entry point thatIntegrationTestcalls per method; it in turn invokes the overridable hooksInitializeFixture()(once per class, before the first test) andInitializeTestCase()(per method). When extending the fixture, override the hooks, notBeforeTestCase().MongoCollectionFixture<TDocument, TInitial>— extendsMongoDatabaseFixturewith collection management; optionally re-seeds data before each test (InitializeDataBeforeEachTestCase).
Configuration
DriverTestConfiguration— static hub forIMongoClient, connection string, default namespace.CreateMongoClient(settings => …)lets tests customize. Multi-shard / multi-mongos clients are first-class.CoreTestConfiguration— companion exposing cluster metadata: server version, wire version, topology type, authentication mode. Used byRequireServerto gate tests by capability.
Driver-event capture and fail-points
EventCapturer— implementsIEventSubscriberand recordsCommandStartedEvent,CommandSucceededEvent, etc. The public constructor takes anIEventFormatter(not anotherIEventSubscriber— the underlyingReflectionEventSubscriberis built internally) and the capturer routes events through it. Filters by event type and predicate; thread-safe queue. The standard pattern for asserting "what commands did the driver actually send".FailPoint— wrapsconfigureFailPointadmin commands. Always useusing (FailPoint.Configure(...)) { … }soDispose()clears the fail-point. A leaked fail-point poisons subsequent tests.MockConnection,MockClusterableServerFactory(underCore/) — for unit tests that don't need a real server (wire-protocol-level expectations, retry logic, server-selection algorithm).EnvironmentVariableProviderMock— overrides env-var lookup in code under test; used with code that readsOIDC_ENV,MONGODB_URI, etc.
JSON-driven helpers
Under Core/JsonDrivenTests/: a small set of event asserters and field-setter helpers (CommandStartedEventAsserter, EventAsserterFactory, RecursiveFieldSetter) used by the spec runners in tests/MongoDB.Driver.Tests/Specifications/. The broader JSON-driven test base classes (test factories, document/value comparers, JSON resource loading) live in the sibling project at tests/MongoDB.Bson.TestHelpers/JsonDrivenTests/, not here.
xUnit extensions
This project's Core/XunitExtensions/ carries RequireServer.cs and RequirePlatform.cs. Generic xUnit machinery (environment gating, the timeout-enforcing test framework) lives in the sibling tests/MongoDB.TestHelpers/ project.
RequireServer(here) — fluent skip predicates:.ClusterType(...),.VersionGreaterThanOrEqualTo("X.Y.Z"),.Authentication(true|false),.RunOn(BsonArray requirements). ThrowsSkipExceptionif not met.[RequirePlatform](here) — skip on unsupported OSes.RequireEnvironment(sibling project,tests/MongoDB.TestHelpers/XunitExtensions/) — skip if env vars are missing (.EnvironmentVariable("OIDC_ENV"),.OperatingSystem(...)).TimeoutEnforcingXunitTestFramework(sibling project,tests/MongoDB.TestHelpers/XunitExtensions/TimeoutEnforcing/) — registered as the test framework viaXunitExtensionsConstants.TimeoutEnforcingXunitFrameworkto enforce a wall-clock timeout (avoids hangs in CI). The runner classes (TimeoutEnforcingTestRunner, etc.) live alongside it.[Category("Integration")]— xUnit trait for organizing tests.X509CertificateLoader(top-level of this project) — a#if !NET8_0_OR_GREATERcompat shim that polyfills the BCL'sSystem.Security.Cryptography.X509Certificates.X509CertificateLoader. Test code can writeX509CertificateLoader.LoadCertificateFromFile(...)/LoadPkcs12FromFile(...)uniformly across TFMs and let the compiler pick the BCL type on modern frameworks and this shim below. Don't reach for the deprecatednew X509Certificate2(string)constructors in new code.
Sibling helper projects
tests/MongoDB.Bson.TestHelpers/— BSON-specific assertions,BsonDocument/BsonArraycomparers, JSON-driven test base classes used by BSON spec runners.tests/MongoDB.TestHelpers/— cross-cutting xUnit extensions, value-attributes (parameterized tests), category traits.
Common pitfalls
- Tests cannot run in parallel. Per root
AGENTS.md. The fixture model assumes single-threaded execution within a class; collection state is shared. - Leaked fail-points. Always
using. If a test asserts mid-fail-point and the assertion throws,Disposeruns. - Silent skips.
RequireServerandRequireEnvironmentthrowSkipException, surfacing as "skipped" not "failed". Read the test output, don't trust a green status. - Fixture lifecycle confusion.
MongoDatabaseFixtureis per-class (xUnitIClassFixture).InitializeTestCaseruns before each method, but collections accumulate across the class run and are dropped only at class teardown (Dispose), not between individual tests. Per-method DB creation is not the model — share the DB. - Embedded JSON resource paths. New spec-test JSON files dropped under the repo-root
specifications/tree are already picked up by the single repo-wide<EmbeddedResource>glob inMongoDB.Driver.Tests.csproj(see the Specifications-areaAGENTS.mdfor the glob); the failure modes are wrong on-disk location (undertests/MongoDB.Driver.Tests/Specifications/instead of repo-rootspecifications/) or aPathPrefix/PathPrefixesmismatch on the legacy runner. Both yield zero tests discovered, silently. - Per-mongos behavior. Some tests must target a specific mongos (sharded).
DriverTestConfigurationexposes per-mongos clients; reach for them when behavior depends on transaction routing.
How to test the helpers
These are libraries — no tests of their own to run. Validate via the test projects that consume them:
dotnet test tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj -f net10.0
dotnet test tests/MongoDB.Bson.Tests/MongoDB.Bson.Tests.csproj -f net10.0When changing helpers in a way that affects skip behavior, scan the test logs for unexpected skips before declaring done.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

