jasontaylordev / CleanArchitecture

Clean Architecture Solution Template for ASP.NET Core
MIT License
16.13k stars 3.45k forks source link

Integration Tests for Entity CRUD Operations in CleanArchitecture.Infrastructure #1195

Open samanazadi1996 opened 2 weeks ago

samanazadi1996 commented 2 weeks ago

Integration Tests for Entity CRUD Operations in CleanArchitecture.Infrastructure

This pull request introduces integration tests for CRUD (Create, Read, Update, Delete) operations in the CleanArchitecture.Infrastructure project. The key changes and additions are as follows:

Key Changes

1. BaseEfRepoTestFixture Class

2. EfRepositoryAdd Class

3. EfRepositoryDelete Class

4. EfRepositoryUpdate Class

Summary

These integration tests are designed to enhance the robustness of the application by verifying the correct implementation of CRUD operations within the infrastructure layer. They provide a foundation for future tests and help ensure data consistency and reliability.

Please review the changes and provide feedback.

DennisJansenDev commented 2 weeks ago

Albeit I applaud the effort into this PR, I don't see the added value in this, you're testing the methods on the EFCore DbSet? Why would you want to test the EFCore package? The code is already tested by the EFCore team 😅 See: https://github.com/dotnet/efcore/tree/main/test

samanazadi1996 commented 2 weeks ago

Albeit I applaud the effort into this PR, I don't see the added value in this, you're testing the methods on the EFCore DbSet? Why would you want to test the EFCore package? The code is already tested by the EFCore team 😅 See: https://github.com/dotnet/efcore/tree/main/test

Actually, these tests are for ApplicationDbContext

DennisJansenDev commented 2 weeks ago

Albeit I applaud the effort into this PR, I don't see the added value in this, you're testing the methods on the EFCore DbSet? Why would you want to test the EFCore package? The code is already tested by the EFCore team 😅 See: https://github.com/dotnet/efcore/tree/main/test

Actually, these tests are for ApplicationDbContext

No they are not, the ApplicationDbContext inherits from the EFCore DbContext. In the ApplicationDbContext you use DbSet which creates the "repository" for the entity and exposes the Add(create), Update(update), Delete(delete) and IQueryable(read) on the TEntity. Which in fact you are testing in your tests.