You have a problem with your test. When you verify that the data is stored in the database, you should verify that it is in the database, and not that the repository says that it is in the database.
If you are testing the functionality of a repository, you cannot test this functionality by asking if it is executed correctly. This is the equivalent of the word to someone. "Did you do it right?" They are going to say yes.
Imagine a repository never commits. Your test will pass fine, but the data will not be in the database.
So, I would do to open a connection (pure SQL) with the database and verify that the data was saved correctly. You only need to select the counter (*) before and after to make sure that the user has been saved. If you do this, you can also avoid using the name SearchSubscribersByU.
If you are testing the functionality of a repository, you cannot trust the repository by definition.
Matthew farwell
source share