-
Notifications
You must be signed in to change notification settings - Fork 0
Feature Comparison With Alternatives
aryehcitron@gmail.com edited this page May 25, 2026
·
5 revisions
Applies to: InMemoryEmulator.MongoDB v1.0.0+
| InMemory Emulator | Mongo2Go | Testcontainers.MongoDB | Real MongoDB | |
|---|---|---|---|---|
| Architecture | In-process fake — implements IMongoClient/IMongoCollection<T> directly in C# |
Managed wrapper around real mongod binary (v4.4.4). Downloads and launches a child process on a random port |
Docker container running official MongoDB image. Managed via Testcontainers .NET library | Full MongoDB server (standalone, replica set, or sharded cluster) |
| Install size | ~NuGet package only (< 1 MB) | ~200 MB (bundled mongod + mongoimport + mongoexport for Win/Linux/macOS) |
~200–600 MB Docker image (depending on MongoDB version) | ~300 MB+ server install |
| Typical startup time | ~0 ms (object construction) | 2–5 s (extract binaries + start mongod + wait for port) |
5–15 s (Docker pull + container start + health check) | N/A (always running) |
| Connection mode | Direct in-memory method calls | Real TCP connection (localhost) | Real TCP connection (mapped Docker port) | Real TCP/TLS connection |
| Supported MongoDB version behavior | v5.0+ semantics (operator-level reimplementation) | v4.4.4 (bundled binary; fixed) | Any (choose Docker image tag) | Any |
| Platform | Any OS that runs .NET 8.0+ | Windows, Linux, macOS (requires matching native binaries) | Any OS with Docker Desktop or daemon | Any supported platform |
| Status | Active development (frequent releases) | Maintained (last release Jan 2025); MongoDB binary stuck at v4.4.4 | Active (follows Testcontainers .NET releases) | Production |
| InMemory Emulator | Mongo2Go | Testcontainers.MongoDB | Real MongoDB | |
|---|---|---|---|---|
| Pricing | ✅ Free | ✅ Free | ✅ Free | ❌ Pay (Atlas) or self-host |
| In-process (no external deps) | ✅ | ❌ External mongod process |
❌ Docker container | ❌ Requires network |
| Fast startup | ✅ Instant (~0 ms) | ❌ 2–5 s | ❌ 5–15 s | ❌ Already running / provisioning |
| Docker required | ✅ No | ✅ No | ❌ Yes | ✅ No (self-host) |
| Works offline | ✅ | ✅ (after first download) | ❌ Atlas requires internet | |
| CI-friendly | ✅ All environments (no deps) | |||
| Multiple instances / parallel | ✅ One per test class (zero cost) | mongod per instance (port exhaustion risk) |
||
| Test isolation | ✅ New instance per test | ❌ Shared; risk of data leakage | ||
| Stable under load | ✅ No sockets/network | mongod crashes on CI |
✅ (at cost) | |
| Platform support | ✅ Any (.NET 8.0+) | ✅ Any Docker host | ✅ Any | |
| No special cleanup | ✅ GC disposes | mongod, deletes data dir) |
||
| Community sentiment | ✅ New; fast-growing | ✅ Popular | ✅ Standard | |
| .NET target | .NET 8.0+ | .NET Framework 4.7.2 / .NET Standard 2.1 | .NET Standard 2.0+ | N/A |
| License | MIT | MIT | MIT | SSPL (server) |
| Stars | — | 408 | — | — |
Legend:
- ✅ = Full support
⚠️ = Partial support (details in Notes)- ❌ = Not supported
- N/A = Not applicable
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| InsertOne / InsertMany | ✅ | ✅ | ✅ | ✅ | |
| Find (filter, sort, skip, limit, projection) | ✅ | ✅ | ✅ | ✅ | |
| UpdateOne / UpdateMany | ✅ | ✅ | ✅ | ✅ | |
| ReplaceOne | ✅ | ✅ | ✅ | ✅ | |
| DeleteOne / DeleteMany | ✅ | ✅ | ✅ | ✅ | |
| FindOneAndDelete | ✅ | ✅ | ✅ | ✅ | |
| FindOneAndReplace | ✅ | ✅ | ✅ | ✅ | |
| FindOneAndUpdate | ✅ | ✅ | ✅ | ✅ | |
| BulkWrite (ordered/unordered) | ✅ | ✅ | ✅ | ✅ | |
| CountDocuments / EstimatedDocumentCount | ✅ | ✅ | ✅ | ✅ | |
| Distinct | ✅ | ✅ | ✅ | ✅ | InMemory: array unwinding supported |
| Aggregate | ✅ | ✅ | ✅ | ✅ | InMemory: 34 stages |
| AsQueryable (LINQ) | ✅ | ✅ | ✅ | ✅ | InMemory: LINQ3 |
| Upsert (insert on no match) | ✅ | ✅ | ✅ | ✅ | |
| ArrayFilters (positional updates) | ✅ | ✅ | ✅ | ✅ | |
| Pipeline-style updates | ✅ | ✅ | ✅ | ✅ | |
Auto _id generation |
✅ | ✅ | ✅ | ✅ | InMemory: writes back to POCO |
| MapReduce | ❌ | ✅ | ✅ | ✅ | InMemory: throws NotSupportedException (deprecated in MongoDB 5.0+) |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $eq | ✅ | ✅ | ✅ | ✅ | |
| $ne | ✅ | ✅ | ✅ | ✅ | |
| $gt | ✅ | ✅ | ✅ | ✅ | |
| $gte | ✅ | ✅ | ✅ | ✅ | |
| $lt | ✅ | ✅ | ✅ | ✅ | |
| $lte | ✅ | ✅ | ✅ | ✅ | |
| $in | ✅ | ✅ | ✅ | ✅ | InMemory: supports BsonRegularExpression values |
| $nin | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $and | ✅ | ✅ | ✅ | ✅ | |
| $or | ✅ | ✅ | ✅ | ✅ | |
| $nor | ✅ | ✅ | ✅ | ✅ | |
| $not | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $exists | ✅ | ✅ | ✅ | ✅ | |
| $type | ✅ | ✅ | ✅ | ✅ | InMemory: all BSON type aliases (timestamp, javascript, minKey, maxKey, etc.) |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $all | ✅ | ✅ | ✅ | ✅ | InMemory: nested $elemMatch + scalar matching |
| $elemMatch | ✅ | ✅ | ✅ | ✅ | |
| $size | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $regex (with $options) | ✅ | ✅ | ✅ | ✅ | |
| $mod | ✅ | ✅ | ✅ | ✅ | InMemory: exact comparison, truncation per spec |
| $expr | ✅ | ✅ | ✅ | ✅ | |
| $text | ✅ | ✅ | ✅ | ✅ | InMemory: case-insensitive word matching |
| $jsonSchema | ✅ | ✅ | ✅ | ✅ | InMemory: allOf/anyOf/oneOf/not |
| $where (JavaScript) | ✅ | ✅ | ✅ | ✅ | InMemory: requires JsTriggers package |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $bitsAllSet | ✅ | ✅ | ✅ | ✅ | |
| $bitsAllClear | ✅ | ✅ | ✅ | ✅ | |
| $bitsAnySet | ✅ | ✅ | ✅ | ✅ | |
| $bitsAnyClear | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $geoWithin ($geometry, $centerSphere) | ✅ | ✅ | ✅ | ✅ | InMemory: real calculations via NetTopologySuite |
| $geoIntersects | ✅ | ✅ | ✅ | ✅ | |
| $near ($maxDistance, $minDistance) | ✅ | ✅ | ✅ | ✅ | |
| $nearSphere | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $set | ✅ | ✅ | ✅ | ✅ | |
| $unset | ✅ | ✅ | ✅ | ✅ | |
| $inc | ✅ | ✅ | ✅ | ✅ | |
| $mul | ✅ | ✅ | ✅ | ✅ | |
| $min | ✅ | ✅ | ✅ | ✅ | |
| $max | ✅ | ✅ | ✅ | ✅ | |
| $rename | ✅ | ✅ | ✅ | ✅ | |
| $currentDate | ✅ | ✅ | ✅ | ✅ | |
| $setOnInsert | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $push (with $each, $position, $sort, $slice) | ✅ | ✅ | ✅ | ✅ | InMemory: negative $position for end-relative |
| $pull (with subdocument matching) | ✅ | ✅ | ✅ | ✅ | |
| $pullAll | ✅ | ✅ | ✅ | ✅ | |
| $addToSet (with $each) | ✅ | ✅ | ✅ | ✅ | |
| $pop | ✅ | ✅ | ✅ | ✅ | |
| $bit (AND, OR, XOR) | ✅ | ✅ | ✅ | ✅ | |
| $ (first matching positional) | ✅ | ✅ | ✅ | ✅ | |
| $[] (all elements) | ✅ | ✅ | ✅ | ✅ | |
| $[<identifier>] (filtered positional) | ✅ | ✅ | ✅ | ✅ | InMemory: with arrayFilters |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| Inclusion / exclusion | ✅ | ✅ | ✅ | ✅ | |
| _id exclusion | ✅ | ✅ | ✅ | ✅ | |
| Dot-notation nested fields | ✅ | ✅ | ✅ | ✅ | |
| $slice (array) | ✅ | ✅ | ✅ | ✅ | |
| $elemMatch | ✅ | ✅ | ✅ | ✅ | |
| $meta (textScore) | ✅ | ✅ | ✅ | ✅ | InMemory: gracefully skipped in sort |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $match | ✅ | ✅ | ✅ | ✅ | |
| $project | ✅ | ✅ | ✅ | ✅ | |
| $addFields / $set | ✅ | ✅ | ✅ | ✅ | |
| $unset | ✅ | ✅ | ✅ | ✅ | |
| $group | ✅ | ✅ | ✅ | ✅ | InMemory: 19+ accumulators |
| $sort | ✅ | ✅ | ✅ | ✅ | |
| $limit | ✅ | ✅ | ✅ | ✅ | |
| $skip | ✅ | ✅ | ✅ | ✅ | |
| $unwind | ✅ | ✅ | ✅ | ✅ | preserveNullAndEmptyArrays supported |
| $lookup | ✅ | ✅ | ✅ | ✅ | |
| $replaceRoot / $replaceWith | ✅ | ✅ | ✅ | ✅ | |
| $count | ✅ | ✅ | ✅ | ✅ | |
| $sortByCount | ✅ | ✅ | ✅ | ✅ | |
| $sample | ✅ | ✅ | ✅ | ✅ | |
| $facet | ✅ | ✅ | ✅ | ✅ | |
| $bucket | ✅ | ✅ | ✅ | ✅ | |
| $bucketAuto | ✅ | ✅ | ✅ | ✅ | InMemory: custom output accumulators |
| $unionWith | ✅ | ✅ | ✅ | ✅ | |
| $graphLookup | ✅ | ✅ | ✅ | ✅ | InMemory: recursive with deduplication |
| $redact | ✅ | ✅ | ✅ | ✅ | |
| $merge | ✅ | ✅ | ✅ | ✅ | |
| $out | ✅ | ✅ | ✅ | ✅ | |
| $setWindowFields | ✅ | ✅ | ✅ | ✅ | InMemory: 22 window functions |
| $densify | ✅ | ✅ | ✅ | ✅ | |
| $fill | ✅ | ✅ | ✅ | ✅ | |
| $documents | ✅ | ✅ | ✅ | ✅ | |
| $collStats | ✅ | ✅ | ✅ | ✅ | InMemory: synthetic values |
| $indexStats | ✅ | ✅ | ✅ | ✅ | InMemory: synthetic values |
| $geoNear | ✅ | ✅ | ✅ | ✅ | InMemory: real geometric calculations |
| $search | ❌ | ❌ | ✅ (Atlas) | InMemory: basic substring (not Atlas Search) | |
| $searchMeta | ❌ | ❌ | ✅ (Atlas) | InMemory: stub | |
| $vectorSearch | ✅ | ❌ | ❌ | ✅ (Atlas) | InMemory: brute-force exact computation |
| $changeStream | ❌ | ✅ | ✅ | ✅ | InMemory: use Watch() API instead |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $sum / $avg / $min / $max | ✅ | ✅ | ✅ | ✅ | |
| $first / $last | ✅ | ✅ | ✅ | ✅ | |
| $push / $addToSet | ✅ | ✅ | ✅ | ✅ | |
| $count | ✅ | ✅ | ✅ | ✅ | |
| $mergeObjects | ✅ | ✅ | ✅ | ✅ | |
| $stdDevPop / $stdDevSamp | ✅ | ✅ | ✅ | ✅ | |
| $top / $bottom / $topN / $bottomN | ✅ | ✅ | ✅ | ✅ | |
| $firstN / $lastN / $maxN / $minN | ✅ | ✅ | ✅ | ✅ | |
| $median / $percentile | ✅ | ✅ | ✅ | ✅ | |
| $accumulator (JavaScript) | ✅ | ✅ | ✅ | ✅ | InMemory: requires JsTriggers package |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $sum / $avg / $min / $max / $count | ✅ | ✅ | ✅ | ✅ | |
| $push / $addToSet / $first / $last | ✅ | ✅ | ✅ | ✅ | |
| $stdDevPop / $stdDevSamp | ✅ | ✅ | ✅ | ✅ | |
| $rank / $denseRank / $documentNumber | ✅ | ✅ | ✅ | ✅ | |
| $shift | ✅ | ✅ | ✅ | ✅ | |
| $expMovingAvg | ✅ | ✅ | ✅ | ✅ | |
| $derivative / $integral | ✅ | ✅ | ✅ | ✅ | |
| $covariancePop / $covarianceSamp | ✅ | ✅ | ✅ | ✅ | |
| $linearFill / $locf | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $add / $subtract / $multiply / $divide | ✅ | ✅ | ✅ | ✅ | |
| $mod / $abs / $ceil / $floor | ✅ | ✅ | ✅ | ✅ | |
| $round / $trunc | ✅ | ✅ | ✅ | ✅ | InMemory: IEEE 754 round-to-even |
| $pow / $sqrt / $log / $log10 / $ln / $exp | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $sin / $cos / $tan | ✅ | ✅ | ✅ | ✅ | |
| $asin / $acos / $atan / $atan2 | ✅ | ✅ | ✅ | ✅ | |
| $degreesToRadians / $radiansToDegrees | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $concat / $toLower / $toUpper | ✅ | ✅ | ✅ | ✅ | |
| $trim / $ltrim / $rtrim | ✅ | ✅ | ✅ | ✅ | |
| $substr / $substrBytes / $substrCP | ✅ | ✅ | ✅ | ✅ | |
| $strLenBytes / $strLenCP | ✅ | ✅ | ✅ | ✅ | |
| $indexOfBytes / $indexOfCP | ✅ | ✅ | ✅ | ✅ | |
| $split / $strcasecmp | ✅ | ✅ | ✅ | ✅ | |
| $replaceOne / $replaceAll | ✅ | ✅ | ✅ | ✅ | |
| $regexMatch / $regexFind / $regexFindAll | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $cmp / $eq / $ne / $gt / $gte / $lt / $lte | ✅ | ✅ | ✅ | ✅ | |
| $cond / $ifNull / $switch | ✅ | ✅ | ✅ | ✅ | |
| $and / $or / $not | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $arrayElemAt / $size / $isArray | ✅ | ✅ | ✅ | ✅ | |
| $concatArrays / $in / $filter / $map | ✅ | ✅ | ✅ | ✅ | |
| $reduce / $reverseArray / $range / $slice | ✅ | ✅ | ✅ | ✅ | |
| $first / $last / $sortArray | ✅ | ✅ | ✅ | ✅ | |
| $objectToArray / $arrayToObject | ✅ | ✅ | ✅ | ✅ | |
| $zip / $indexOfArray | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $setUnion / $setIntersection / $setDifference | ✅ | ✅ | ✅ | ✅ | |
| $setEquals / $setIsSubset | ✅ | ✅ | ✅ | ✅ | |
| $anyElementTrue / $allElementsTrue | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $type / $convert / $isNumber | ✅ | ✅ | ✅ | ✅ | |
| $toBool / $toInt / $toLong / $toDouble / $toDecimal | ✅ | ✅ | ✅ | ✅ | |
| $toString / $toDate / $toObjectId | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $year / $month / $dayOfMonth / $hour / $minute / $second / $millisecond | ✅ | ✅ | ✅ | ✅ | |
| $dayOfWeek / $dayOfYear / $week / $isoWeek / $isoWeekYear / $isoDayOfWeek | ✅ | ✅ | ✅ | ✅ | |
| $dateToString / $dateFromString | ✅ | ✅ | ✅ | ✅ | InMemory: format + timezone support |
| $dateAdd / $dateSubtract / $dateDiff | ✅ | ✅ | ✅ | ✅ | InMemory: quarter unit supported |
| $dateTrunc / $dateFromParts / $dateToParts | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $mergeObjects | ✅ | ✅ | ✅ | ✅ | |
| $getField / $setField / $unsetField | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $bitAnd / $bitOr / $bitXor / $bitNot | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $literal / $let | ✅ | ✅ | ✅ | ✅ | |
| $binarySize / $bsonSize | ✅ | ✅ | ✅ | ✅ | |
| $rand / $sampleRate | ✅ | ✅ | ✅ | ✅ | |
| $toHashedIndexKey | ✅ | ✅ | ✅ | ✅ | |
| $function (JavaScript) | ✅ | ✅ | ✅ | ✅ | InMemory: requires JsTriggers package |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $tsIncrement / $tsSecond | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| Unique indexes | ✅ Enforced | ✅ | ✅ | ✅ | |
| Compound indexes (multi-field uniqueness) | ✅ Enforced | ✅ | ✅ | ✅ | |
| Sparse indexes | ✅ Enforced | ✅ | ✅ | ✅ | |
| Partial filter indexes | ✅ Enforced | ✅ | ✅ | ✅ | |
| TTL indexes | ✅ Enforced (lazy eviction) | ✅ | ✅ | ✅ | InMemory: expired docs removed on query, not by background thread |
| Text indexes | ✅ Accepted | ✅ | ✅ | ✅ | |
| 2dsphere indexes | ✅ Accepted | ✅ | ✅ | ✅ | |
| Hashed indexes | ✅ Accepted | ✅ | ✅ | ✅ | InMemory: no sharding simulation |
| Wildcard indexes | ✅ Accepted | ✅ | ✅ | ✅ | |
| CreateOne / CreateMany / List / DropOne / DropAll | ✅ | ✅ | ✅ | ✅ | |
| Duplicate key error (proper error codes) | ✅ | ✅ | ✅ | ✅ | |
| Index used for query optimization | ❌ | ✅ | ✅ | ✅ | InMemory: always full scan; indexes stored but not used for optimization |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| GetCollection() | ✅ | ✅ | ✅ | ✅ | |
| CreateCollection (capped, timeseries, validator, viewOn) | ✅ | ✅ | ✅ | ✅ | |
| DropCollection | ✅ | ✅ | ✅ | ✅ | |
| ListCollections / ListCollectionNames | ✅ | ✅ | ✅ | ✅ | |
| RenameCollection (with DropTarget) | ✅ | ✅ | ✅ | ✅ | |
| CreateView (pipeline-backed) | ✅ | ✅ | ✅ | ✅ | |
| Database-level Aggregate | ✅ | ✅ | ✅ | ✅ | |
| GetDatabase / ListDatabases / DropDatabase | ✅ | ✅ | ✅ | ✅ | |
| RunCommand | ✅ | ✅ | ✅ | InMemory: supports ping, buildInfo, serverStatus, hostInfo, connectionStatus, listCommands, collStats, dbStats, count, distinct, create, drop, createIndexes, dropIndexes, aggregate, explain. Not supported: hello/isMaster, collMod, currentOp, validate, filemd5, renameCollection (via RunCommand), convertToCapped, reIndex, compact, user/role management, replication, sharding commands. Unknown commands throw CommandNotFound (code 59). |
|
| WithReadConcern / WithWriteConcern / WithReadPreference | ✅ Stored | ✅ | ✅ | ✅ | InMemory: accepted but not enforced |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| Collection-level Watch() | ✅ | ✅ | ✅ | ✅ | |
| Database-level Watch() | ✅ | ✅ | ✅ | ✅ | |
| Client-level Watch() | ✅ | ✅ | ✅ | ✅ | |
| Resume tokens | ✅ | ✅ | ✅ | ✅ | |
| OperationType: Insert, Update, Replace, Delete | ✅ | ✅ | ✅ | ✅ | |
| FullDocument / FullDocumentBeforeChange | ✅ | ✅ | ✅ | ✅ | |
| Pipeline filtering on events | ✅ | ✅ | ✅ | ✅ | |
| Events from all write operations | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| StartSession / StartTransaction | ✅ | ✅ | ✅ | ✅ | |
| CommitTransaction / AbortTransaction | ✅ | ✅ | ✅ | ✅ | |
| Snapshot isolation | ✅ | ✅ | ✅ | ✅ | |
| Automatic rollback on abort | ✅ | ✅ | ✅ | ✅ | |
| Multi-document transactions | ✅ | ✅ | ✅ | Mongo2Go: requires singleNodeReplSet: true (adds ~5s to startup) |
|
| Distributed / sharded transactions | ❌ | ❌ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| required / bsonType | ✅ | ✅ | ✅ | ✅ | |
| minimum / maximum | ✅ | ✅ | ✅ | ✅ | |
| minLength / maxLength / pattern | ✅ | ✅ | ✅ | ✅ | |
| enum | ✅ | ✅ | ✅ | ✅ | |
| minItems / maxItems | ✅ | ✅ | ✅ | ✅ | |
| additionalProperties | ✅ | ✅ | ✅ | ✅ | |
| allOf / anyOf / oneOf / not | ✅ | ✅ | ✅ | ✅ | |
| validationAction / validationLevel | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| Capped collection (FIFO eviction) | ✅ | ✅ | ✅ | ✅ | maxDocuments + maxSize |
| Tailable cursor / TailableAwait | ✅ | ✅ | ✅ | ✅ | |
| Cannot delete from capped | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| UploadFromBytes / UploadFromStream | ✅ | ✅ | ✅ | ✅ | |
| DownloadAsBytes / DownloadToStream | ✅ | ✅ | ✅ | ✅ | |
| Find / Delete / Rename | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| $geoWithin / $geoIntersects / $near / $nearSphere | ✅ | ✅ | ✅ | ✅ | InMemory: NetTopologySuite for real geometric calculations |
| $geoNear aggregation stage | ✅ | ✅ | ✅ | ✅ | |
| 2dsphere index | ✅ | ✅ | ✅ | ✅ |
| InMemory | Mongo2Go | Testcontainers | Real MongoDB | Notes | |
|---|---|---|---|---|---|
| Fault injection | ✅ | ❌ | ❌ | ❌ | InMemory exclusive: per-operation error simulation |
| Operation logging | ✅ | ❌ | ❌ | ❌ | InMemory exclusive: query/operation recording for assertions |
| State export/import (JSON) | ✅ | ❌ | ❌ | Mongo2Go: mongoexport/mongoimport only | |
| DI integration (UseInMemoryMongoDB) | ✅ | ❌ | ❌ | ❌ | InMemory exclusive: one-line service replacement |
| Vector search ($vectorSearch) | ✅ | ❌ | ❌ | ✅ (Atlas) | InMemory: brute-force computation |
| $search / $searchMeta (text) | ❌ | ❌ | ✅ (Atlas) | InMemory: basic substring (not Atlas Search) | |
| JavaScript expressions ($function, $accumulator, $where) | ✅ | ✅ | ✅ | ✅ | InMemory: via optional JsTriggers package (Jint) |
| SDK version drift detection | ✅ | ❌ | ❌ | ❌ | InMemory exclusive: alerts when driver adds new members |
| InMemoryMongo.Create() factory | ✅ | ❌ | ❌ | ❌ | InMemory exclusive: instant standalone collection |
| Collation (culture-aware) | ✅ | ✅ | ✅ | ✅ | InMemory: .NET CultureInfo (may differ from ICU on edge cases) |
| Views (pipeline-backed) | ✅ | ✅ | ✅ | ✅ | |
| Time series collections | ✅ | ✅ | ✅ | InMemory: stub (accepted in CreateCollection) | |
| Authentication / authorization | ❌ | ✅ | ✅ | ✅ | InMemory: not simulated |
| Replica set topology | ❌ | ✅ | ✅ | Mongo2Go: single-node replica set only | |
| Sharding | ❌ | ❌ | ✅ | ✅ | |
| Client-Side Field Level Encryption (CSFLE) | ❌ | ❌ | ✅ | ✅ | Requires native cryptd libraries |
| Queryable Encryption | ❌ | ❌ | ✅ | ✅ | Requires server-side support |
| Command monitoring / APM events | ❌ | ✅ | ✅ | ✅ | InMemory: ClusterConfigurator events not fired |
| Query plan optimization (indexes used for queries) | ❌ | ✅ | ✅ | ✅ | InMemory: always full scan |
| Aggregation 100 MB memory limit | ❌ | ✅ | ✅ | ✅ | InMemory: unconstrained |
| Cursor idle timeout | ❌ | ✅ | ✅ | ✅ | InMemory: cursors never expire |
| Data persistence across restarts | ✅ | ✅ | ✅ | InMemory: via ExportState/ImportState; Testcontainers: volume mount | |
| Multiple databases | ✅ | ✅ | ✅ | ✅ | |
| mongoimport / mongoexport | ❌ | ✅ | ✅ | ✅ | Mongo2Go: built-in convenience wrappers |
Counts based on the detailed tables above. "Applicable" excludes cloud-only Atlas features ($search, $vectorSearch) that no local testing tool supports identically.
| Category | InMemory | Mongo2Go | Testcontainers | Real MongoDB |
|---|---|---|---|---|
| CRUD operations (18) | ✅ 17/18 | ✅ 18/18 | ✅ 18/18 | ✅ 18/18 |
| Filter operators (27) | ✅ 27/27 | ✅ 27/27 | ✅ 27/27 | ✅ 27/27 |
| Update operators (18) | ✅ 18/18 | ✅ 18/18 | ✅ 18/18 | ✅ 18/18 |
| Projection operators (6) | ✅ 6/6 | ✅ 6/6 | ✅ 6/6 | ✅ 6/6 |
| Aggregation stages (34) | ✅ 32/34 | ✅ 32/34 | ✅ 32/34 | ✅ 34/34 |
| Expression operators (113+) | ✅ 113/113 | ✅ 113/113 | ✅ 113/113 | ✅ 113/113 |
| Group accumulators (19+) | ✅ 19/19 | ✅ 19/19 | ✅ 19/19 | ✅ 19/19 |
| Window functions (22) | ✅ 22/22 | ✅ 22/22 | ✅ 22/22 | ✅ 22/22 |
| Index types (9) | ✅ 9/9 | ✅ 9/9 | ✅ 9/9 | |
| Change stream features (8) | ✅ 8/8 | ✅ 8/8 | ✅ 8/8 | ✅ 8/8 |
| Transaction features (6) | ✅ 6/6 | ✅ 6/6 | ||
| InMemory-exclusive features (6) | ✅ 6/6 | ❌ 0/6 | ❌ 0/6 | ❌ 0/6 |
- ✅ 113+ aggregation expression operators — full pipeline support with 34 stages
- ✅ Instant startup — no Docker, no binary download, no network
- ✅ Perfect test isolation — new instance per test, no shared state, no cleanup
- ✅ Fault injection — simulate errors per-operation for retry/resilience testing
- ✅ Operation logging — record all operations for test assertions
- ✅ State export/import — JSON-based snapshot and restore for test setup
- ✅ DI integration — one-line setup via
UseInMemoryMongoDB() - ✅ No platform restrictions — any OS that runs .NET 8.0+
- ✅ No port conflicts — multiple instances run in parallel without coordination
- ✅ SDK drift detection — alerts when new driver interface members appear
InMemory Emulator Limitations (things Mongo2Go / Testcontainers / Real MongoDB do that InMemory doesn't)
- ❌ MapReduce — deprecated in MongoDB 5.0+; throws
NotSupportedException - ❌ Query plan optimization — indexes stored but never used for query routing; always full scan
- ❌ Aggregation 100 MB memory limit — unconstrained (no
allowDiskUseenforcement) - ❌ Authentication / authorization — ReadConcern/WriteConcern/ReadPreference stored but not enforced
- ❌ Replica set topology — single in-memory instance (no failover/election simulation)
- ❌ Sharding — no shard key routing or chunk migration
- ❌ Client-Side Field Level Encryption (CSFLE) — requires native
mongocryptdlibraries - ❌ Command monitoring / APM events —
ClusterConfiguratorevent subscribers not fired - ❌ Cursor idle timeout — in-memory cursors never expire
- ❌ Atlas Search ($search full fidelity) — basic substring only, not NLP/BM25
⚠️ TTL eviction — lazy (on query) rather than background thread⚠️ Collation — uses .NETCultureInfo; may differ from ICU on edge cases
- Unit tests and integration tests in CI
- Local development without Docker or binary dependencies
- Testing retry logic via fault injection
- Fast feedback loops (instant startup, zero teardown)
- Deterministic, reproducible test runs
- No external dependencies
- When you need full aggregation pipeline testing (34 stages, 113+ operators)
- Parallel test execution without coordination
- When you need 100% MongoDB wire-protocol fidelity
- When testing features not reimplemented (MapReduce, command monitoring)
- Legacy projects on .NET Framework 4.7.2 / .NET Standard 2.1
- When Docker isn't available but you need "real" MongoDB behavior
- Full-fidelity end-to-end testing with Docker available
- Testing specific MongoDB server versions (choose image tag)
- Testing sharding, encryption, or distributed transactions
- When you need APM/command monitoring event verification
- When Docker is already part of your CI infrastructure
- Final acceptance testing against production-like environment
- Performance benchmarking with real indexes and query plans
- Verifying authentication, RBAC, and encryption
- Testing with production data volumes
- Atlas-specific features ($search with BM25, $vectorSearch with ANN)
- Known Limitations — Full list of behavioral differences
- Features — Complete feature documentation with examples
- Migration Guide — Step-by-step migration from Mongo2Go / Testcontainers
- Getting Started — Quick setup guide
Getting Started
Integration & Dependency Injection
Data Management
Reference
- Feature Comparison
- Features
- Filter & Update Operators
- Aggregation Pipeline
- LINQ Support
- API Reference
Help