Run tests. Example: (covered earlier in Mock DbContext) ✅ Fast, reliable for unit or light integration tests, but not suitable for relational behaviors (like joins, transactions). 🔟 How Do You Implement TestContainers for Integration Testing?
TestContainers spins up real Docker containers (SQL Server, Redis) for integration
testing, simulating production.
Example:
using Testcontainers.MsSql;
var sqlContainer = new MsSqlBuilder()
.WithPassword("yourStrong(!)Password")
.Build();
await sqlContainer.StartAsync();
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseSqlServer(sqlContainer.GetConnectionString())
.Options;
// Use context in tests
Follow :
✅ Benefits:
- Real database behavior
- CI/CD friendly
- Close to production setup
Deployment & Hosting
How to Deploy an ASP.NET Core App to IIS?
IIS (Internet Information Services) can host ASP.NET Core apps via the ASP.NET Core
Module, which forwards requests to Kestrel.
Steps: