Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

samanazadi1996
Copy link

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

  • Provides a base class for integration tests, setting up an in-memory SQLite database for testing purposes.
  • Ensures the database connection is opened and schema is created before tests are executed.

2. EfRepositoryAdd Class

  • Contains tests to verify the behavior of adding entities to the database.
  • Tests ensure that entities are not persisted without calling SaveChanges and are correctly persisted after calling SaveChanges.

3. EfRepositoryDelete Class

  • Includes tests to validate the deletion of entities from the database.
  • Tests ensure that entities are correctly removed after calling SaveChanges.

4. EfRepositoryUpdate Class

  • Consists of tests to check the update functionality of entities.
  • Tests ensure that updated entities are correctly persisted after calling SaveChanges.

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
Copy link

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
Copy link
Author

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants