Unit testing Entity Framework and SQL-Server RRS feed

  • General discussion

  • the code sample focuses on setting up data for doing unit testing with Entity Framework by using a base class which another class inherits to create temporary data that is inserted into SQL-Server table(s), unit test do their assertion then in the test class cleans up all data which was created is removed from the database table(s). Other methods used for unit testing such EntityFramework.MoqHelper create in memory data that represents the entities representing data in the backend database which means they don’t touch the database and therefore are faster to run test. The downside is there are no metrics to gauge performance on hitting the actual data.  So in this code sample we actually hit against the database, first to create the data, next to run against the data and finally to clean up data that we created prior to running our test (thinking arrange, act assert).  

    MSDN code sample

    The mirror version in C# on MSDN is here.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Sunday, March 19, 2017 6:12 PM