Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing with Entity Framework

I want to test my Entities that are built using Entity Framework. My concern is that using Entity Framework means directly working with data source. So any ideas how to unit testing Entity Framework based components?

like image 476
Muhammad Soliman Avatar asked Nov 28 '08 19:11

Muhammad Soliman


People also ask

What frameworks have you used for unit testing?

JUnit is an open-source unit testing framework for a test-driven development environment. It supports the core concept of “first testing then coding”. This framework is specifically designed for Java programming language. In this, data is first tested and then it is inserted in the piece of code.

What is mocking framework C#?

Mocking Frameworks (Moq, NSubstitute, Rhino Mocks, FakeItEasy, and NMock3) are used to create fake objects. We can stub, i.e., completely replace the body of member and function. It is used to isolate each dependency and help developers in performing unit testing in a concise, quick, and reliable way.

What is dbContextOptions?

The dbContextOptions carries the configuration information needed to configure the DbContext. The dbContextOptions can also be configured using the OnConfiguring method. This method gets the DbContextOptionsBuilder as its argument. It is then used to create the dbContextOptions.


2 Answers

For Enity Framework 4, this looks promising: Testability and Entity Framework 4.0

like image 125
Hans Kesting Avatar answered Sep 28 '22 12:09

Hans Kesting


Apparently it's very hard. Eloquently put by Erik here - TDD and ADO.NET Entity Framework

like image 27
gef Avatar answered Sep 28 '22 11:09

gef