-
Notifications
You must be signed in to change notification settings - Fork 8
/
AlamofireXmlToObjects3Tests.swift
88 lines (73 loc) · 2.51 KB
/
AlamofireXmlToObjects3Tests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// AlamofireXmlToObjects3Tests.swift
// AlamofireXmlToObjects
//
// Created by Edwin Vermeer on 6/5/16.
// Copyright © 2016 evict. All rights reserved.
//
import XCTest
import Alamofire
import XMLDictionary
import EVReflection
class AllGames: EVObject {
var __name: String?
var StateProv: StateProvObject?
}
class StateProvObject: EVObject {
var __name: String?
var _stateprov_name: String?
var _stateprov_id: String?
var game: [Game] = []
}
class Game: EVObject {
var __name: String?
var _game_id: Int = 0
var _game_name: String?
var _update_time: Date?
var lastdraw_date: String?
var lastdraw_numbers: String?
var nextdraw_date: String?
var jackpot: Jackpot?
}
class Jackpot: EVObject {
var __text: String?
var _date: String?
}
class AlamofireXmlToObjects3Tests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
EVReflection.setBundleIdentifier(AllGames.self)
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testResponseObject() {
// This is an example of a functional test case.
let URL: URLConvertible = "https://raw.githubusercontent.com/evermeer/AlamofireXmlToObjects/master/AlamofireXmlToObjectsTests/sample3_xml"
let expectation = self.expectation(description: "\(URL)")
DataRequest.outputXMLresult = true
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
dateFormatter.dateFormat = "ddd yyyy'-'MM'-'dd' 'HH':'mm':'ss Z"
EVReflection.setDateFormatter(dateFormatter)
Alamofire.request(URL)
.responseObject { (response: DataResponse<AllGames>) in
expectation.fulfill()
if let error = response.result.error {
XCTAssert(false, "ERROR: \(error.localizedDescription)")
} else {
if let result = response.result.value {
print("\(result.description)")
} else {
XCTAssert(false, "no result from service")
}
}
}
waitForExpectations(timeout: 10) { error in
XCTAssertNil(error, "\(error)")
}
}
}