SlideShare a Scribd company logo
1 of 36
Download to read offline
2017/07/07 17'22Testable Code - By cho
Page 1 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
;DRS@ D -NCD;DRS@ D -NCD;DRS@ D -NCD
HMFGT@ G@MF HMFGT@ G@MF LD BNLHMFGT@ G@MF HMFGT@ G@MF LD BNLHMFGT@ G@MF HMFGT@ G@MF LD BNL
2017/07/07 17'22Testable Code - By cho
Page 2 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
MHS ;DRSMHS ;DRSMHS ;DRS
. - , - . , . -
. . .
!
2017/07/07 17'22Testable Code - By cho
Page 3 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
G MHS ;DRSG MHS ;DRSG MHS ;DRS
HMCR O N DLR D@
@BH HS@SDR BG@MFD
, @G @G @G
; ; )
2017/07/07 17'22Testable Code - By cho
Page 4 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
MHSMHSMHS
. ,
- -
,
- - , ,
. .
!
2017/07/07 17'22Testable Code - By cho
Page 5 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
2N2N2N
,D TMBSHNM@
2017/07/07 17'22Testable Code - By cho
Page 6 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
,D TMBSHNM@,D TMBSHNM@,D TMBSHNM@
- - , - -
, - -
!
2017/07/07 17'22Testable Code - By cho
Page 7 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
T D TMBSHNMT D TMBSHNMT D TMBSHNM
, , , . , .
, - . , .
!
;GD ETMBSHNM @ @ R DU@ T@SDR SGD R@LD DRT S U@ TD
FHUDM SGD R@LD @ FTLDMS U@ TD R
/U@ T@SHNM NE SGD DRT S CNDR MNS B@TRD @M
RDL@MSHB@ N RD U@ D RHCD DEEDBS N NTSOTS RTBG @R
LTS@SHNM NE LTS@ D N IDBSR N NTSOTS SN 3 CDUHBDR
2017/07/07 17'22Testable Code - By cho
Page 8 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
/W@LO D
/W@LO D
/W@LO D/W@LO D
class SomeDataModel {
func convertDate(date: NSDate) -> NSDate {
var returnDate = date
let closingDate = StringToDate(StoreModel.sharedInstance().closingDate)
if closingDate.hour >= 12 {
returnDate.day += 1
} else {
returnDate.day -= 1
}
return date
}
}
// Test
func testConvertDate() {
StoreModel.sharedInstance().closingDate = "0000"
XCTAssert(convertDate(date: someDate))
StoreModel.sharedInstance().closingDate = "1200"
XCTAssert(convertDate(date: someDate))
}
2017/07/07 17'22Testable Code - By cho
Page 9 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
;HO N;HO N;HO N
; MNS SN DED DMBD HLOT D HMRS@MBD RS@SD; MNS SN DED DMBD HLOT D HMRS@MBD RS@SD; MNS SN DED DMBD HLOT D HMRS@MBD RS@SD
DSBDSBDSB
2017/07/07 17'22Testable Code - By cho
Page 10 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
/W@LO D
/W@LO D
/W@LO D/W@LO D
class SomeDataModel {
func convertDate(date: NSDate, closingTime: NSDate) -> NSDate {
var returnDate = date
let closingDate = StringToDate(closingTime)
if closingDate.hour >= 12 {
returnDate.day += 1
} else {
returnDate.day -= 1
}
return date
}
}
// Test
func testConvertDate() {
XCTAssert(convertDate(date: someDate, "0000"))
XCTAssert(convertDate(date: someDate, "1200"))
}
2017/07/07 17'22Testable Code - By cho
Page 11 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
struct SomeState {
var current: Int
}
class SomeDataModel {
var state = SomeState(current: 0)
func step001() {
guard state.current == 0 else { fatalError() }
// do some thing
state.current = 1
}
func step002() {
guard state.current == 1 else { fatalError() }
// do some thing
state.current = 2
}
}
// Test
func testStep002() {
let model = SomeDataModel()
model.step001()
2017/07/07 17'22Testable Code - By cho
Page 12 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
;HO N
;HO N
;HO N;HO N
HSD BNLONR@ D BNCD
HSD BNLONR@ D BNCD
HSD BNLONR@ D BNCDHSD BNLONR@ D BNCD
2017/07/07 17'22Testable Code - By cho
Page 13 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D
@MC ON D ET@MC ON D ET@MC ON D ET
2017/07/07 17'22Testable Code - By cho
Page 14 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D
@MC ON D ET@MC ON D ET@MC ON D ET
# Unix Commands
# recovery all deleted files in git
$ git status | grep delete | cut -d: -f2 | xargs git checkout
2017/07/07 17'22Testable Code - By cho
Page 15 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D
@MC ON D ET@MC ON D ET@MC ON D ET
# GStreamer
protocol > source > format > codec > filter > sink
http alsa mp4 mp3 mixer alsa
ftp v4l2 ogg mpeg4 effect file
file mic avi h263 ... xvideo
... ... ... ... …
2017/07/07 17'22Testable Code - By cho
Page 16 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
struct SomeState {
let current: Int
}
class SomeDataModel {
var state = SomeState(current: 0)
func step001(state: SomeState) -> SomeState {
guard state.current == 0 else { fatalError() }
// do some thing
return SomeState(state: 1)
}
func step002(state: SomeState) -> SomeState {
guard state.current == 1 else { fatalError() }
// do some thing
return SomeState(state: 2)
}
}
// Test
func testStep002() {
let model = SomeDataModel()
let state = model.step002(state: SomeState(current: 1))
2017/07/07 17'22Testable Code - By cho
Page 17 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
;HO N;HO N;HO N
: 3.: 3.: 3.
: :HMF D DRONMRH H HS HMBHO D
ODM - NRDC HMBHO D
HR NU :T RSHSTSHNM HMBHO D
3 3MSD E@BD :DF DF@SHNM HMBHO D
. .DODMCDMB 3MUD RHNM HMBHO D
2017/07/07 17'22Testable Code - By cho
Page 18 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
:::
:HMF D DRONMRH HS HMBHO D:HMF D DRONMRH HS HMBHO D:HMF D DRONMRH HS HMBHO D
. - .
. . - , . ,
. , . .
.
!
2017/07/07 17'22Testable Code - By cho
Page 19 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
/W@LO D/W@LO D/W@LO D
func foo(completion: (error: NSError?) -> Void) {
var sent = false
for _ in 0..<5 {
sent = checkDataSent()
if sent {
break
}
sleep(1)
}
if sent {
doSomethingReallyWantTo(completion)
} else {
completion(error: NSError(domain: "error domain", code: 1, userInfo: nil))
}
}
2017/07/07 17'22Testable Code - By cho
Page 20 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
/W@LO D
/W@LO D
/W@LO D/W@LO D
func untilDataSent(completion: (sent: Bool) -> Void) {
var sent = false
for _ in 0..<5 {
sent = checkDataSent()
if sent {
break
}
sleep(1)
}
completion(sent: sent)
}
func foo(completion: (error: NSError?) -> Void) {
untilDataSent { sent in
if sent {
doSomethingReallyWantTo(completion)
} else {
completion(error: NSError(domain: "error domain", code: 1, userInfo: nil))
}
}
}
2017/07/07 17'22Testable Code - By cho
Page 21 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
/W@LO D
/W@LO D
/W@LO D/W@LO D
func untilDataSent(completion: (sent: Bool) -> Void) {
…
}
func foo(until: (completion: (sent: Bool) -> Void) -> Void, completion: (error: NSError?) ->
until { sent in
if sent {
doSomethingReallyWantTo(error: nil)
} else {
completion(error: NSError(domain: "error domain", code: 1, userInfo: nil))
}
}
}
// Test
func testFoo() {
expectationWithDescription(@"expectation")
foo ({ $0(sent: true }) { error in XCTAssertNil(error) }
foo ({ $0(sent: false }) { error in XCTAssertNil(error) }
waitForExpectationsWithTimeout(1, handler: nil)
}
2017/07/07 17'22Testable Code - By cho
Page 22 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
;HOR;HOR;HOR
; MNS SN DED DMBD HLOT D HMRS@MBD RS@SD DSB
HSD BNLONR@ D BNCD
:
2017/07/07 17'22Testable Code - By cho
Page 23 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
,@C :LD R,@C :LD R,@C :LD R
:HCD DEEDBSR
1 N @ :S@SD
:HMF DSNM
.DODMCDMB
NMF ETMBSHNM
@ D N IDBSR HM BNMRS TBSN
D @ MN @UNHCHMF F N @ U@ H@ D TS DSSHMF
RHMF DSNM Z HMF @ NUD NT BNCD
2017/07/07 17'22Testable Code - By cho
Page 24 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
@ D N IDBSR HM BNMRS TBSN@ D N IDBSR HM BNMRS TBSN@ D N IDBSR HM BNMRS TBSN
class A { }
class B {
var a: A?
init() {
a = A()
}
}
2017/07/07 17'22Testable Code - By cho
Page 25 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
@ D N IDBSR HM BNMRS TBSN@ D N IDBSR HM BNMRS TBSN@ D N IDBSR HM BNMRS TBSN
class A { }
class B {
var a: A?
init(a: A) {
self.a = a
}
}
// Test
func testB() {
let b = B(a: TestableA())
}
2017/07/07 17'22Testable Code - By cho
Page 26 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
:NLD ;DBGMHPTDR:NLD ;DBGMHPTDR:NLD ;DBGMHPTDR
2017/07/07 17'22Testable Code - By cho
Page 27 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
NB :ST DSBNB :ST DSBNB :ST DSB
2017/07/07 17'22Testable Code - By cho
Page 28 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
UD HCDUD HCDUD HCD
2017/07/07 17'22Testable Code - By cho
Page 29 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
/W@LO D/W@LO D/W@LO D
class PrinterManager {
func printSomething(str: String) {
let printer = Printer(name: NSUserDefaults.standardUserDefaults().stringForKey("Current P
printer.printString(str)
}
}
2017/07/07 17'22Testable Code - By cho
Page 30 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
/W@LO D/W@LO D/W@LO D
class PrinterManager {
func printSomething(str: String) {
currentPrinter.printString(str)
}
func currentPrinter() -> Printer {
return Printer(name: NSUserDefaults.standardUserDefaults().stringForKey("Current Printer"
}
}
class TestablePrinterManager: PrinterManager {
override func currentPrinter() -> Printer {
return TestPrinter()
}
}
2017/07/07 17'22Testable Code - By cho
Page 31 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
:D@L:D@L:D@L
. . -
. - .
!
2017/07/07 17'22Testable Code - By cho
Page 32 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
/M@ HMF NHMS/M@ HMF NHMS/M@ HMF NHMS
. - . .
. .
!
2017/07/07 17'22Testable Code - By cho
Page 33 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
.DODMCDMB 3MIDBSHNM.DODMCDMB 3MIDBSHNM.DODMCDMB 3MIDBSHNM
class SomeModel {
var identifier: String!
func doSomething() {
let store = CommonStore.sharedInstance()
self.identifier = store.createSomething()
}
}
2017/07/07 17'22Testable Code - By cho
Page 34 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
.DODMCDMB 3MIDBSHNM
.DODMCDMB 3MIDBSHNM
.DODMCDMB 3MIDBSHNM.DODMCDMB 3MIDBSHNM
class AppFactory {
func register(object: AnyObject, type: AnyType) { }
func get(type: AnyType) -> AnyObject { }
}
class SomeModel {
var identifier: String!
func doSomething() {
let store = AppFactory.sharedInstance().store()
self.identifier = store.createSomething()
}
}
func test() {
AppFactory.sharedInstance().register(MockStore(), type: CommonStore.self)
// test from here
}
2017/07/07 17'22Testable Code - By cho
Page 35 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
G@S L@ DR @ FNNC TMHS SDRSG@S L@ DR @ FNNC TMHS SDRSG@S L@ DR @ FNNC TMHS SDRS
D@C@ D
- D@M
2HFG BNUD @FD
-NUD R NTMC U@ TD
-NUD R HMU@ HC U@ TD
2017/07/07 17'22Testable Code - By cho
Page 36 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1
DED DMBDRDED DMBDRDED DMBDR
HSHMF ;DRS@ D -NCD
: 3.
GSSO( LHR N GDUD BNL BNCD DUHD D R FTHCD
GSSOR( DM H HODCH@ N F H H : 3.? N IDBS
N HDMSDC?CDRHFM

More Related Content

Similar to Testable Code

Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
David Gómez García
 
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Igalia
 
Dtrace и немного магии
Dtrace и немного магииDtrace и немного магии
Dtrace и немного магии
Dan Kruchinin
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
Moriyoshi Koizumi
 

Similar to Testable Code (20)

Varnish kann alles
Varnish kann allesVarnish kann alles
Varnish kann alles
 
Code Review 001
Code Review 001Code Review 001
Code Review 001
 
Pledge in OpenBSD
Pledge in OpenBSDPledge in OpenBSD
Pledge in OpenBSD
 
eProsima RPC over DDS - Connext Conf London October 2015
eProsima RPC over DDS - Connext Conf London October 2015 eProsima RPC over DDS - Connext Conf London October 2015
eProsima RPC over DDS - Connext Conf London October 2015
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Let's talks about string operations in C++17
Let's talks about string operations in C++17Let's talks about string operations in C++17
Let's talks about string operations in C++17
 
From logs to metrics
From logs to metricsFrom logs to metrics
From logs to metrics
 
Keynote 1 - Engineering Software Analytics Studies
Keynote 1 - Engineering Software Analytics StudiesKeynote 1 - Engineering Software Analytics Studies
Keynote 1 - Engineering Software Analytics Studies
 
Php 7.x 8.0 and hhvm and
Php 7.x 8.0 and hhvm and Php 7.x 8.0 and hhvm and
Php 7.x 8.0 and hhvm and
 
Cto cn
Cto cnCto cn
Cto cn
 
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
Midiendo la calidad de código en WTF/Min (Revisado EUI Abril 2014)
 
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
Stranger in These Parts. A Hired Gun in the JS Corral (JSConf US 2012)
 
Real-time Fluid Simulation in Shadow of the Tomb Raider
Real-time Fluid Simulation in Shadow of the Tomb RaiderReal-time Fluid Simulation in Shadow of the Tomb Raider
Real-time Fluid Simulation in Shadow of the Tomb Raider
 
Real-time Fluid Simulation in Shadow of the Tomb Raider
Real-time Fluid Simulation in Shadow of the Tomb RaiderReal-time Fluid Simulation in Shadow of the Tomb Raider
Real-time Fluid Simulation in Shadow of the Tomb Raider
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
Dtrace и немного магии
Dtrace и немного магииDtrace и немного магии
Dtrace и немного магии
 
How to be a smart contract engineer
How to be a smart contract engineerHow to be a smart contract engineer
How to be a smart contract engineer
 
Inexpensive Datamasking for MySQL with ProxySQL - data anonymization for deve...
Inexpensive Datamasking for MySQL with ProxySQL - data anonymization for deve...Inexpensive Datamasking for MySQL with ProxySQL - data anonymization for deve...
Inexpensive Datamasking for MySQL with ProxySQL - data anonymization for deve...
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 

Testable Code

  • 1. 2017/07/07 17'22Testable Code - By cho Page 1 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 ;DRS@ D -NCD;DRS@ D -NCD;DRS@ D -NCD HMFGT@ G@MF HMFGT@ G@MF LD BNLHMFGT@ G@MF HMFGT@ G@MF LD BNLHMFGT@ G@MF HMFGT@ G@MF LD BNL
  • 2. 2017/07/07 17'22Testable Code - By cho Page 2 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 MHS ;DRSMHS ;DRSMHS ;DRS . - , - . , . - . . . !
  • 3. 2017/07/07 17'22Testable Code - By cho Page 3 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 G MHS ;DRSG MHS ;DRSG MHS ;DRS HMCR O N DLR D@ @BH HS@SDR BG@MFD , @G @G @G ; ; )
  • 4. 2017/07/07 17'22Testable Code - By cho Page 4 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 MHSMHSMHS . , - - , - - , , . . !
  • 5. 2017/07/07 17'22Testable Code - By cho Page 5 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 2N2N2N ,D TMBSHNM@
  • 6. 2017/07/07 17'22Testable Code - By cho Page 6 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 ,D TMBSHNM@,D TMBSHNM@,D TMBSHNM@ - - , - - , - - !
  • 7. 2017/07/07 17'22Testable Code - By cho Page 7 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 T D TMBSHNMT D TMBSHNMT D TMBSHNM , , , . , . , - . , . ! ;GD ETMBSHNM @ @ R DU@ T@SDR SGD R@LD DRT S U@ TD FHUDM SGD R@LD @ FTLDMS U@ TD R /U@ T@SHNM NE SGD DRT S CNDR MNS B@TRD @M RDL@MSHB@ N RD U@ D RHCD DEEDBS N NTSOTS RTBG @R LTS@SHNM NE LTS@ D N IDBSR N NTSOTS SN 3 CDUHBDR
  • 8. 2017/07/07 17'22Testable Code - By cho Page 8 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 /W@LO D /W@LO D /W@LO D/W@LO D class SomeDataModel { func convertDate(date: NSDate) -> NSDate { var returnDate = date let closingDate = StringToDate(StoreModel.sharedInstance().closingDate) if closingDate.hour >= 12 { returnDate.day += 1 } else { returnDate.day -= 1 } return date } } // Test func testConvertDate() { StoreModel.sharedInstance().closingDate = "0000" XCTAssert(convertDate(date: someDate)) StoreModel.sharedInstance().closingDate = "1200" XCTAssert(convertDate(date: someDate)) }
  • 9. 2017/07/07 17'22Testable Code - By cho Page 9 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 ;HO N;HO N;HO N ; MNS SN DED DMBD HLOT D HMRS@MBD RS@SD; MNS SN DED DMBD HLOT D HMRS@MBD RS@SD; MNS SN DED DMBD HLOT D HMRS@MBD RS@SD DSBDSBDSB
  • 10. 2017/07/07 17'22Testable Code - By cho Page 10 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 /W@LO D /W@LO D /W@LO D/W@LO D class SomeDataModel { func convertDate(date: NSDate, closingTime: NSDate) -> NSDate { var returnDate = date let closingDate = StringToDate(closingTime) if closingDate.hour >= 12 { returnDate.day += 1 } else { returnDate.day -= 1 } return date } } // Test func testConvertDate() { XCTAssert(convertDate(date: someDate, "0000")) XCTAssert(convertDate(date: someDate, "1200")) }
  • 11. 2017/07/07 17'22Testable Code - By cho Page 11 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 struct SomeState { var current: Int } class SomeDataModel { var state = SomeState(current: 0) func step001() { guard state.current == 0 else { fatalError() } // do some thing state.current = 1 } func step002() { guard state.current == 1 else { fatalError() } // do some thing state.current = 2 } } // Test func testStep002() { let model = SomeDataModel() model.step001()
  • 12. 2017/07/07 17'22Testable Code - By cho Page 12 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 ;HO N ;HO N ;HO N;HO N HSD BNLONR@ D BNCD HSD BNLONR@ D BNCD HSD BNLONR@ D BNCDHSD BNLONR@ D BNCD
  • 13. 2017/07/07 17'22Testable Code - By cho Page 13 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 -NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D @MC ON D ET@MC ON D ET@MC ON D ET
  • 14. 2017/07/07 17'22Testable Code - By cho Page 14 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 -NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D @MC ON D ET@MC ON D ET@MC ON D ET # Unix Commands # recovery all deleted files in git $ git status | grep delete | cut -d: -f2 | xargs git checkout
  • 15. 2017/07/07 17'22Testable Code - By cho Page 15 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 -NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D-NLONRHSHNM L@ DR SGHMFR ZDWH D @MC ON D ET@MC ON D ET@MC ON D ET # GStreamer protocol > source > format > codec > filter > sink http alsa mp4 mp3 mixer alsa ftp v4l2 ogg mpeg4 effect file file mic avi h263 ... xvideo ... ... ... ... …
  • 16. 2017/07/07 17'22Testable Code - By cho Page 16 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 struct SomeState { let current: Int } class SomeDataModel { var state = SomeState(current: 0) func step001(state: SomeState) -> SomeState { guard state.current == 0 else { fatalError() } // do some thing return SomeState(state: 1) } func step002(state: SomeState) -> SomeState { guard state.current == 1 else { fatalError() } // do some thing return SomeState(state: 2) } } // Test func testStep002() { let model = SomeDataModel() let state = model.step002(state: SomeState(current: 1))
  • 17. 2017/07/07 17'22Testable Code - By cho Page 17 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 ;HO N;HO N;HO N : 3.: 3.: 3. : :HMF D DRONMRH H HS HMBHO D ODM - NRDC HMBHO D HR NU :T RSHSTSHNM HMBHO D 3 3MSD E@BD :DF DF@SHNM HMBHO D . .DODMCDMB 3MUD RHNM HMBHO D
  • 18. 2017/07/07 17'22Testable Code - By cho Page 18 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 ::: :HMF D DRONMRH HS HMBHO D:HMF D DRONMRH HS HMBHO D:HMF D DRONMRH HS HMBHO D . - . . . - , . , . , . . . !
  • 19. 2017/07/07 17'22Testable Code - By cho Page 19 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 /W@LO D/W@LO D/W@LO D func foo(completion: (error: NSError?) -> Void) { var sent = false for _ in 0..<5 { sent = checkDataSent() if sent { break } sleep(1) } if sent { doSomethingReallyWantTo(completion) } else { completion(error: NSError(domain: "error domain", code: 1, userInfo: nil)) } }
  • 20. 2017/07/07 17'22Testable Code - By cho Page 20 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 /W@LO D /W@LO D /W@LO D/W@LO D func untilDataSent(completion: (sent: Bool) -> Void) { var sent = false for _ in 0..<5 { sent = checkDataSent() if sent { break } sleep(1) } completion(sent: sent) } func foo(completion: (error: NSError?) -> Void) { untilDataSent { sent in if sent { doSomethingReallyWantTo(completion) } else { completion(error: NSError(domain: "error domain", code: 1, userInfo: nil)) } } }
  • 21. 2017/07/07 17'22Testable Code - By cho Page 21 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 /W@LO D /W@LO D /W@LO D/W@LO D func untilDataSent(completion: (sent: Bool) -> Void) { … } func foo(until: (completion: (sent: Bool) -> Void) -> Void, completion: (error: NSError?) -> until { sent in if sent { doSomethingReallyWantTo(error: nil) } else { completion(error: NSError(domain: "error domain", code: 1, userInfo: nil)) } } } // Test func testFoo() { expectationWithDescription(@"expectation") foo ({ $0(sent: true }) { error in XCTAssertNil(error) } foo ({ $0(sent: false }) { error in XCTAssertNil(error) } waitForExpectationsWithTimeout(1, handler: nil) }
  • 22. 2017/07/07 17'22Testable Code - By cho Page 22 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 ;HOR;HOR;HOR ; MNS SN DED DMBD HLOT D HMRS@MBD RS@SD DSB HSD BNLONR@ D BNCD :
  • 23. 2017/07/07 17'22Testable Code - By cho Page 23 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 ,@C :LD R,@C :LD R,@C :LD R :HCD DEEDBSR 1 N @ :S@SD :HMF DSNM .DODMCDMB NMF ETMBSHNM @ D N IDBSR HM BNMRS TBSN D @ MN @UNHCHMF F N @ U@ H@ D TS DSSHMF RHMF DSNM Z HMF @ NUD NT BNCD
  • 24. 2017/07/07 17'22Testable Code - By cho Page 24 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 @ D N IDBSR HM BNMRS TBSN@ D N IDBSR HM BNMRS TBSN@ D N IDBSR HM BNMRS TBSN class A { } class B { var a: A? init() { a = A() } }
  • 25. 2017/07/07 17'22Testable Code - By cho Page 25 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 @ D N IDBSR HM BNMRS TBSN@ D N IDBSR HM BNMRS TBSN@ D N IDBSR HM BNMRS TBSN class A { } class B { var a: A? init(a: A) { self.a = a } } // Test func testB() { let b = B(a: TestableA()) }
  • 26. 2017/07/07 17'22Testable Code - By cho Page 26 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 :NLD ;DBGMHPTDR:NLD ;DBGMHPTDR:NLD ;DBGMHPTDR
  • 27. 2017/07/07 17'22Testable Code - By cho Page 27 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 NB :ST DSBNB :ST DSBNB :ST DSB
  • 28. 2017/07/07 17'22Testable Code - By cho Page 28 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 UD HCDUD HCDUD HCD
  • 29. 2017/07/07 17'22Testable Code - By cho Page 29 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 /W@LO D/W@LO D/W@LO D class PrinterManager { func printSomething(str: String) { let printer = Printer(name: NSUserDefaults.standardUserDefaults().stringForKey("Current P printer.printString(str) } }
  • 30. 2017/07/07 17'22Testable Code - By cho Page 30 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 /W@LO D/W@LO D/W@LO D class PrinterManager { func printSomething(str: String) { currentPrinter.printString(str) } func currentPrinter() -> Printer { return Printer(name: NSUserDefaults.standardUserDefaults().stringForKey("Current Printer" } } class TestablePrinterManager: PrinterManager { override func currentPrinter() -> Printer { return TestPrinter() } }
  • 31. 2017/07/07 17'22Testable Code - By cho Page 31 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 :D@L:D@L:D@L . . - . - . !
  • 32. 2017/07/07 17'22Testable Code - By cho Page 32 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 /M@ HMF NHMS/M@ HMF NHMS/M@ HMF NHMS . - . . . . !
  • 33. 2017/07/07 17'22Testable Code - By cho Page 33 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 .DODMCDMB 3MIDBSHNM.DODMCDMB 3MIDBSHNM.DODMCDMB 3MIDBSHNM class SomeModel { var identifier: String! func doSomething() { let store = CommonStore.sharedInstance() self.identifier = store.createSomething() } }
  • 34. 2017/07/07 17'22Testable Code - By cho Page 34 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 .DODMCDMB 3MIDBSHNM .DODMCDMB 3MIDBSHNM .DODMCDMB 3MIDBSHNM.DODMCDMB 3MIDBSHNM class AppFactory { func register(object: AnyObject, type: AnyType) { } func get(type: AnyType) -> AnyObject { } } class SomeModel { var identifier: String! func doSomething() { let store = AppFactory.sharedInstance().store() self.identifier = store.createSomething() } } func test() { AppFactory.sharedInstance().register(MockStore(), type: CommonStore.self) // test from here }
  • 35. 2017/07/07 17'22Testable Code - By cho Page 35 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 G@S L@ DR @ FNNC TMHS SDRSG@S L@ DR @ FNNC TMHS SDRSG@S L@ DR @ FNNC TMHS SDRS D@C@ D - D@M 2HFG BNUD @FD -NUD R NTMC U@ TD -NUD R HMU@ HC U@ TD
  • 36. 2017/07/07 17'22Testable Code - By cho Page 36 of 36http://10.17.244.123'8080/md/TestableCode.md?print=1 DED DMBDRDED DMBDRDED DMBDR HSHMF ;DRS@ D -NCD : 3. GSSO( LHR N GDUD BNL BNCD DUHD D R FTHCD GSSOR( DM H HODCH@ N F H H : 3.? N IDBS N HDMSDC?CDRHFM