From the course: C#: Design Patterns Part 1

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Factory Method design pattern for unit testing

Factory Method design pattern for unit testing - Python Tutorial

From the course: C#: Design Patterns Part 1

Factory Method design pattern for unit testing

- [Instructor] Now, we'll go back to the HPlusSports application, to look at.net cores built in dependency injection framework. How it can use the factory method pattern, and how we can use that, to improve our unit tests. We'll start in startup CS, for the really short version of how this app is already using dependency injection. A service collection is being built with the builder pattern to create a service provider. That service provider, is going to create the controllers and their dependencies when routed to, by MVC. In the configure services method, we're registering how those dependencies, should be created. If I go to definition for Dell configure services, I'm adding the DB context and the repositories to that service collection that can start up. I can look at configure services from the core DLL. Here we're registering the service types, order and sales person. This is the configuration that returns the service…

Contents