concept unit test in category entity framework

This is an excerpt from Manning's book Entity Framework Core in Action.
Using interfaces and DI together means your application is more loosely coupled; you can replace a class with another class that matches the same interface. This is especially useful in unit testing: you can provide a replacement version of the service with another, simpler class that implements the interface (called mockingor faking in unit tests).
OK, if you’re still with me, I assume you know what unit testing is and have at least written some unit tests. I’m not going to cover the differences between unit tests and integration tests, or acceptance tests, and so on. I’m also not here to persuade you that unit tests are useful; I assume you’re convinced of their usefulness and want to learn the tips and techniques for unit testing an EF Core application.
Figure 15.1 I believe wholeheartedly in unit tests, but that doesn’t mean I want to spend a lot of time developing or running them. My approach is to try to be efficient at using unit tests, and that splits into developing quickly and not having to hang around while they run.
![]()
Listing 15.1 A simple example of an xUnit unit test method
[Fact] #1 public void DemoTest() #2 { //SETUP const int someValue = 1; #3 //ATTEMPT var result = someValue * 2; #4 //VERIFY result.ShouldEqual(2); #5 } #1 The [Fact] attribute tells the unit test runner that this method is an xUnit unit test that should be run. #2 The method must be public. It should return void, or, if you’re running async methods, it should return a Task. #3 Typically, you put code here that sets up the data and/or environment for the unit test. #4 This is where you run the code you want to test. #5 Here is where you put the test(s) to check that the result of your test is correct.