29
IoC Container 이이이 ([email protected] ) https:// www.facebook.com/gyuwon.yi http://justhackem.wordpress.com /

Introduction to IoC Container

Embed Size (px)

DESCRIPTION

IoC 컨테이너에 대한 소개입니다. 데모 소스코드는 여기에 있습니다. https://github.com/gyuwon/DotNetPractice/tree/master/IoC

Citation preview

Page 2: Introduction to IoC Container

Contents

• IoC• IoC Container• Test• Demo

Page 3: Introduction to IoC Container

IOC

Page 4: Introduction to IoC Container
Page 5: Introduction to IoC Container

IoC

Page 6: Introduction to IoC Container

IoC

• Inversion of Control

Page 7: Introduction to IoC Container
Page 8: Introduction to IoC Container
Page 9: Introduction to IoC Container

Library

User Code LibraryLibrary Library

Page 10: Introduction to IoC Container

Framework

Framework User CodeUser Code User Code

Page 11: Introduction to IoC Container

IoC Container

Page 12: Introduction to IoC Container

Services

Component Service

Page 13: Introduction to IoC Container

Loose Coupling

Component ServiceIService

Reus

abili

ty

Test

abili

ty

Page 14: Introduction to IoC Container

Dependency Injection

Component

Service

Injector

IService<<create>>

Page 15: Introduction to IoC Container

Service Locator

Component

Service

Locator

IService<<create>>

Page 16: Introduction to IoC Container

Dependency Inversion

Low-Level PackageHigh-Level Package

Component ServiceIService

IService

Page 17: Introduction to IoC Container

Test

Page 18: Introduction to IoC Container

Software Testing

• Automate,• automate,• automate,• and• automate!

Page 19: Introduction to IoC Container

TDD(Test-Driven Development)

Write a test

Fails

Write production codeSucceeds

Clean up

Page 20: Introduction to IoC Container

DDD(Domain-Driven Design)

• f : x -> y• DDD : Domain -> Software

Page 21: Introduction to IoC Container

BDD(Behavior-Driven Development)

Write a specification

Fails

Write production codeSucceeds

Clean up

Dom

ain

Page 22: Introduction to IoC Container

Testability

Test

Component ServiceIService

Fragile or Non-testable

Test Double

IService IoC Container

I’m testable!

Page 23: Introduction to IoC Container

DemoContact Manager

Page 24: Introduction to IoC Container

Architecture

Contact Manager Service

ASP.NET Web API

OWIN Self Host

Entity Framework

SQL Server

Page 25: Introduction to IoC Container

Get Action Method Unit Tests - 1

• Specification?

Page 26: Introduction to IoC Container

Repository Pattern

• IRepository

Page 27: Introduction to IoC Container

Get Action Method Unit Tests - 2

• Moq• Fluent Assertions

Page 28: Introduction to IoC Container

Dependency Injection

• Ninject

Page 29: Introduction to IoC Container

Post Action Method Unit Tests

• Add• SaveChanges• Exception Expected