-
Notifications
You must be signed in to change notification settings - Fork 0
Feature Comparison With Alternatives
| Feature | MongoDB.InMemoryEmulator | Mongo2Go |
|---|---|---|
| Startup time | ~0ms | ~2-5s (downloads/starts mongod) |
| External dependencies | None | Requires mongod binary |
| Docker required | No | No (but downloads binaries) |
| CI compatibility | All environments | May fail on restricted CI |
| Query fidelity | High (operator-level) | Full (real MongoDB) |
| Aggregation pipeline | 34 stages, 100+ operators | Full |
| Transactions | Snapshot isolation | Full replica-set transactions |
| Change streams | Supported | Supported |
| Index enforcement | Unique, TTL, Sparse, Partial | Full |
.NET target |
.NET 8.0+ | .NET Standard 2.0+ |
| Thread safety | ConcurrentDictionary | Process-level |
| Parallel test support | Excellent | Port-conflict risk |
| Fault injection | Built-in | Not available |
| Operation logging | Built-in | Not available |
When to use Mongo2Go: When you need 100% MongoDB wire-protocol fidelity (e.g., testing $graphLookup edge cases or server-side JavaScript).
When to use InMemoryEmulator: When you want fast, reliable, deterministic tests without external dependencies.
| Feature | MongoDB.InMemoryEmulator | Testcontainers.MongoDB |
|---|---|---|
| Startup time | ~0ms | ~5-15s (Docker pull + start) |
| Docker required | No | Yes |
| CI compatibility | All environments | Docker-capable CI only |
| Query fidelity | High | Full (real MongoDB) |
| Resource usage | ~MB (in-process) | ~200MB+ (container) |
| Port conflicts | None | Possible |
| Cleanup | Automatic (GC) | Container stop/remove |
| Fault injection | Built-in | Manual |
| Parallel tests | Excellent | Container-per-test is slow |
When to use Testcontainers: When you need full MongoDB fidelity and have Docker available.
When to use InMemoryEmulator: When Docker isn't available, or you want sub-millisecond test startup.
| Feature | MongoDB.InMemoryEmulator | Manual Mocking (Moq/NSubstitute) |
|---|---|---|
| Setup effort | 1-2 lines | 50+ lines per collection |
| Filter evaluation | Real operator semantics | Not evaluated (returns canned data) |
| Update application | Real operator semantics | Not evaluated |
| Aggregation | 34 stages | Not available |
| Behavioral fidelity | High | None (returns what you set up) |
| Maintenance burden | None | High (breaks on refactor) |
When to use manual mocking: When you specifically want to test that your code calls the right driver methods with the right arguments, regardless of MongoDB behavior.
When to use InMemoryEmulator: When you want to test that your code works correctly with real query and update semantics.
- Migration Guide — Step-by-step migration from Mongo2Go / Testcontainers
- Known Limitations — Where the emulator differs from real MongoDB
Getting Started
Integration & Dependency Injection
Data Management
Reference
- Feature Comparison
- Features
- Filter & Update Operators
- Aggregation Pipeline
- LINQ Support
- API Reference
Help