Skip to content

Instantly share code, notes, and snippets.

@fitomad
Last active December 3, 2015 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/ba54b301de1ba89c0508 to your computer and use it in GitHub Desktop.
Save fitomad/ba54b301de1ba89c0508 to your computer and use it in GitHub Desktop.
func testMovie()
{
// 214756 - Ted 2
// Creamos el objeto que nos ayudara a probar
// la operacion asincrona
let expectation: XCTestExpectation = self.expectationWithDescription("Test fanartForMovie()...")
FanartClient.sharedInstance.fanartForMovie(214756) { (movie, error) -> (Void) in
// Comprobamos si hay error...
XCTAssertNil(error, "Se ha producido un error en el framework")
if let movie = movie
{
print("Tenemos datos para la pelicula: \(movie.name)")
if let posters = movie.posters where !posters.isEmpty
{
print("Tiene \(posters.count) posters")
}
if let clearart = movie.clearartsHD where !clearart.isEmpty
{
print("Tiene \(clearart.count) HD Clearart")
}
if let banners = movie.banners where !banners.isEmpty
{
print("Tiene \(banners.count) banners")
}
}
else
{
print("Esa peli no existe")
}
// La operacion asincrona ha terminado
// Podemos continuar
expectation.fulfill()
}
// Esperamos a que la llamada al servicio termine...
self.waitForExpectationsWithTimeout(10) { (error: NSError?) -> Void in
if let error = error
{
print("Algo ha ido mal mientras esperamos... \(error.description)")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment