Last post Aug 24, 2017 03:17 AM by AngelinaJolie
Aug 18, 2017 09:46 AM|tapan2017|LINK
please tell me anything new exist to test EF repository instead of Mock lib in .Net Core.
if possible please share some good article links. thanks
Aug 18, 2017 10:22 AM|Dmitry Sikorsky|LINK
I think it's the only logical way to test your repositories - to inject and work with fake database (in-memory etc) using fake test repositories.
Aug 21, 2017 10:19 AM|AngelinaJolie|LINK
Did you check this one:
Aug 23, 2017 09:26 AM|tapan2017|LINK
can you please provide some links for fake test repositories.
Aug 23, 2017 09:48 AM|Dmitry Sikorsky|LINK
You could take a look at https://romiller.com/2012/02/14/testing-with-a-fake-dbcontext/ for the ideas, but it is more important to understand how it works.
For example, you have ItemsRepository in your project. It is good practice not to work with ItemsRepository class directly, but create IItemsRepository interface and inject ItemsRepository using the DI. So in your controller, when you need items repository,
you ask DI for the implementation of the IItemsRepository interface and get something, you don't know what exactly.
Then, you can create one more class, let's say, FakeItemsRepository. It should implement IItemsRepository too, but work not with database, but with just objects in memory for example. Or just return hardcoded values. Then you can change the DI registration
and inject not real ItemsRepository, but FakeItemsRepository class as the implementation of the IItemsRepository interface. After that all your controllers that uses that repository will start working with fake one.
Aug 24, 2017 03:17 AM|AngelinaJolie|LINK
I guess that fakes is in Unit testing :
'integration tests verify that different parts of an application work correctly together. Unlike Unit testing,
integration tests frequently involve application infrastructure concerns, such as a database, file system, network resources, or web requests and responses.
Unit tests use fakes or mock objects in place of these concerns, but the purpose of integration tests is to confirm that the system works as expected with these systems.'