Skip to main content

📓 Further Exploration with Testing

We've been refactoring our controllers to utilize the Entity Framework Core functionality but we haven't updated any tests. Entity Framework Core and LINQ allow us to drastically reduce the code in our models and controllers because they do so much work behind the scenes. As long as we follow proper naming conventions, we don't need to add custom code for our models to properly interact with our database. These frameworks are already heavily tested, so it would be redundant for us to test our constructors, getters, and setters.

Similarly, since we use LINQ's database interaction to replace our CRUD methods, we no longer need to test for those, either. In essence, these additions remove the need to test the default functionality of our models entirely. For that reason, we won't be adding more unit tests for these technologies.

If we add custom methods to our models, we should add unit tests for them. However, this is outside the scope of this curriculum. You can find examples of how to unit test with EF Core using the InMemory provider in Microsoft's thorough documentation on the topic.

To add full coverage, you might also consider looking into integration tests in ASP.NET Core, but we leave these topics as further exploration for you. You can find a walkthrough of how to add integration tests to an MVC app in Microsoft's documentation. Although Microsoft's documentation is comprehensive and user-friendly, it does not always line up directly with the technologies we use in our projects, so implementing these testing concepts may take time and patience.

While you are encouraged to look at these resources, testing will not be expected for your remaining C# code reviews.