Integration tests - Setup data in database

c# entity-framework-6 integration-testing

Question

I need to write integration tests for my layer that exposes methods of service. But I need my database to be in a certain state for the tests to pass

For example for testing the GetStoreByID method, I need to have store 1 in my database but not store 2 (for the ko test)

The database is developed and deployed by a another team using a sql project (dacpac)

I use Entity Framework 6.1.3 with an Edmx

What is the best way, in this case, to setup the data in database before tests ?

1
0
5/20/2017 12:36:37 PM

Popular Answer

This link https://msdn.microsoft.com/en-us/library/dn314431(v=vs.113).aspx gives the Microsoft MSDN article on how to write tests using EF6 by faking out the database.

In summary the article covers the subject 'When writing tests for your application it is often desirable to avoid hitting the database. Entity Framework allows you to achieve this by creating a context – with behavior defined by your tests – that makes use of in-memory data.'

0
5/20/2017 2:27:46 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow