馃嚨馃嚜
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension NetworkAdapter { | |
| public func requestServiceSuccess(url: String, method: RequestMethod = .GET, success: SuccessCallback = nil, fail: FailCallback = nil){ | |
| let path = "Sources/data/response.json" | |
| let fileManager = FileManager() | |
| if let content = fileManager.contents(atPath: path), | |
| let successCallback = success { | |
| successCallback(content) | |
| } | |
| } | |
| public func requestServiceFail(url: String, method: RequestMethod = .GET, success: SuccessCallback = nil, fail: FailCallback = nil ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MockUserActions: UserActionProtocol { | |
| private var totalLogin: Int = 0 | |
| private var totalRegister: Int = 0 | |
| func login(nick: String, password: String) { | |
| self.totalLogin += 1 | |
| } | |
| func register(email: String, nick: String, password: String) { | |
| self.totalRegister += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserActions: UserActionProtocol { | |
| func login(nick: String, password: String) { | |
| // consultando a mi servicio original | |
| } | |
| func register(email: String, nick: String, password: String) { | |
| // registrando a mi servicio original | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol UserActionProtocol { | |
| func login(nick: String, password: String) | |
| func register(email: String, nick: String, password: String) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Implementaci贸n que retorna un contenido fijo a diferencia de la Funci贸n original | |
| // Cobertura para el escenario satisfactorio o success | |
| func getRemoteInfoSuccess(success: @escaping([String: Any]) -> Void, fail: @escaping(Error) -> Void ) { | |
| // Definimos una variable como mock | |
| let json: [String: Any] = { | |
| "name": "Luke SkyWalker of Mocker" | |
| } | |
| success(json) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Funci贸n original | |
| func getRemoteInfo(success: @escaping([String: Any]) -> Void, fail: @escaping(Error) -> Void ) { | |
| let url = URL(string: "http://swapi.co/api/people/1/")! | |
| var request = URLRequest(url: url) | |
| request.httpMethod = "GET" | |
| let sessionConf = URLSessionConfiguration.default | |
| let urlSession = URLSession( | |
| configuration: sessionConf, | |
| delegate: nil, | |
| delegateQueue: nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Implementaci贸n que retorna un valor fijo a diferencia de la Funci贸n original | |
| func randomNumber(min: Int, max: Int) -> Int { | |
| return 10 | |
| } | |
| let myNumber = randomNumber(min: 5, max: 31) //retornar谩 siempre 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Funci贸n original | |
| func randomNumber(min: Int, max: Int) -> Int { | |
| // implementaci贸n original | |
| return min + Int(arc4random_uniform(UInt32(max - min + 1))) | |
| } | |
| let myNumber = randomNumber(min: 5, max: 31) //retorna un n煤mero aleatorio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func printFonts() { | |
| let fontFamilyNames = UIFont.familyNames | |
| for familyName in fontFamilyNames { | |
| print("------------------------------") | |
| print("Font Family Name = [\(familyName)]") | |
| let names = UIFont.fontNames(forFamilyName: familyName) | |
| print("Font Names = [\(names)]") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| import pygame | |
| import numpy as np | |
| class Car(pygame.sprite.Sprite): | |
| def __init__(self, surface): | |
| self.bounded_rect = surface.get_rect() | |
| super(Car, self).__init__() |