Skip to content

Instantly share code, notes, and snippets.

@paulstringer
paulstringer / TransferMoney.swift
Last active March 30, 2017 15:03 — forked from mbrowne/TransferMoney.swift
DCI in Swift - simple money transfer example
//TransferMoney context
class TransferMoney: Context {
private let SourceAccount: SourceAccountRole
private let DestinationAccount: DestinationAccountRole
init(source:AccountData, destination:AccountData) {
SourceAccount = source as! SourceAccountRole
DestinationAccount = destination as! DestinationAccountRole
@paulstringer
paulstringer / NSURLSessionTestable.swift
Last active January 27, 2017 08:43
Testable NSURLSession using the 'Subclass and Override Method' technique.
class NSURLSessionTestable: NSURLSession {
var response: NSURLResponse?
var data: NSData?
override func dataTaskWithRequest(request: NSURLRequest, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> NSURLSessionDataTask {
completionHandler(nil, self.response, nil)
return NSURLSessionDataTaskNoOp()