Skip to content

paulcamp/injection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

injection / dependency injection / inversion of control

A demonstration of "inversion of control"

The MVC "EmptyController" class needs an "IStockEngine".

We use a DI Container, in this example "Unity" to resolve what "IStockEngine" is at run-time.

Unit Testing

Here we use Moq to create a Mock and setup what we want to return when its method "LookupItem" is called.
Mocking allows us to isolate things away from what we are trying to test. In this example, the StockEngine in the real world could call a database, thats not something you'd want to be doing in a unit test! What we really test here is that the discount logic is working, we dont care how the StockEngine has been implemented.

Pre Reqs:

.NET 4.7.1

restore Packages

Build

Set Startup project to "WebSales"

Run

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published