Upload
gyuwon-yi
View
1.575
Download
0
Embed Size (px)
DESCRIPTION
IoC 컨테이너에 대한 소개입니다. 데모 소스코드는 여기에 있습니다. https://github.com/gyuwon/DotNetPractice/tree/master/IoC
Citation preview
IoC Container이규원 ([email protected])
https://www.facebook.com/gyuwon.yihttp://justhackem.wordpress.com/
Contents
• IoC• IoC Container• Test• Demo
IOC
IoC
IoC
• Inversion of Control
Library
User Code LibraryLibrary Library
Framework
Framework User CodeUser Code User Code
IoC Container
Services
Component Service
Loose Coupling
Component ServiceIService
Reus
abili
ty
Test
abili
ty
Dependency Injection
Component
Service
Injector
IService<<create>>
Service Locator
Component
Service
Locator
IService<<create>>
Dependency Inversion
Low-Level PackageHigh-Level Package
Component ServiceIService
IService
Test
Software Testing
• Automate,• automate,• automate,• and• automate!
TDD(Test-Driven Development)
Write a test
Fails
Write production codeSucceeds
Clean up
DDD(Domain-Driven Design)
• f : x -> y• DDD : Domain -> Software
BDD(Behavior-Driven Development)
Write a specification
Fails
Write production codeSucceeds
Clean up
Dom
ain
Testability
Test
Component ServiceIService
Fragile or Non-testable
Test Double
IService IoC Container
I’m testable!
DemoContact Manager
Architecture
Contact Manager Service
ASP.NET Web API
OWIN Self Host
Entity Framework
SQL Server
Get Action Method Unit Tests - 1
• Specification?
Repository Pattern
• IRepository
Get Action Method Unit Tests - 2
• Moq• Fluent Assertions
Dependency Injection
• Ninject
Post Action Method Unit Tests
• Add• SaveChanges• Exception Expected