Skip to content

Commit

Permalink
new unit test added
Browse files Browse the repository at this point in the history
  • Loading branch information
evermeer committed Jun 5, 2016
1 parent 8a6a962 commit a0e0f2c
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
8 changes: 8 additions & 0 deletions AlamofireXmlToObjects.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
7F41B6341D041A68009D083B /* sample3_xml in Resources */ = {isa = PBXBuildFile; fileRef = 7F41B6331D041A68009D083B /* sample3_xml */; };
7F41B6361D041BCA009D083B /* AlamofireXmlToObjects3Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F41B6351D041BCA009D083B /* AlamofireXmlToObjects3Tests.swift */; };
7F64D0FD1CBD7BF100AAB0B2 /* AlamofireXmlToObjects2Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F64D0FC1CBD7BF100AAB0B2 /* AlamofireXmlToObjects2Tests.swift */; };
7F64D0FE1CBD7F8A00AAB0B2 /* AlamofireXmlToObjects2Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F64D0FC1CBD7BF100AAB0B2 /* AlamofireXmlToObjects2Tests.swift */; };
7FC3AEB71BC964B400221BFB /* AlamofireXmlToObjects.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FC3AEB61BC964B400221BFB /* AlamofireXmlToObjects.swift */; };
Expand All @@ -30,6 +32,8 @@
7F193D281B371199000C1C34 /* Podfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Podfile; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
7F193D291B371199000C1C34 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
7F2976601BB963100074C85A /* AlamofireXmlToObjectsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AlamofireXmlToObjectsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7F41B6331D041A68009D083B /* sample3_xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = sample3_xml; sourceTree = "<group>"; };
7F41B6351D041BCA009D083B /* AlamofireXmlToObjects3Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlamofireXmlToObjects3Tests.swift; sourceTree = "<group>"; };
7F4A36F71BDCD67100A0F73F /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
7F4A36F81BDCD67100A0F73F /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = "<group>"; };
7F5B07B21BC997920077F674 /* AlamofireXmlToObjectsTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AlamofireXmlToObjectsTests-Bridging-Header.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -104,8 +108,10 @@
children = (
7FC3AEBB1BC964BF00221BFB /* AlamofireXmlToObjectsTests.swift */,
7F64D0FC1CBD7BF100AAB0B2 /* AlamofireXmlToObjects2Tests.swift */,
7F41B6351D041BCA009D083B /* AlamofireXmlToObjects3Tests.swift */,
7FC3AEBF1BC964BF00221BFB /* sample_xml */,
7F64D0FB1CBD7B5800AAB0B2 /* sampl2_xml */,
7F41B6331D041A68009D083B /* sample3_xml */,
7FC3AED11BC97FB400221BFB /* Supporting Files */,
);
path = AlamofireXmlToObjectsTests;
Expand Down Expand Up @@ -228,6 +234,7 @@
buildActionMask = 2147483647;
files = (
7FC3AECB1BC964BF00221BFB /* sample_xml in Resources */,
7F41B6341D041A68009D083B /* sample3_xml in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -339,6 +346,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7F41B6361D041BCA009D083B /* AlamofireXmlToObjects3Tests.swift in Sources */,
7F64D0FD1CBD7BF100AAB0B2 /* AlamofireXmlToObjects2Tests.swift in Sources */,
7FC3AEB71BC964B400221BFB /* AlamofireXmlToObjects.swift in Sources */,
7FC3AEC31BC964BF00221BFB /* AlamofireXmlToObjectsTests.swift in Sources */,
Expand Down
63 changes: 63 additions & 0 deletions AlamofireXmlToObjectsTests/AlamofireXmlToObjects3Tests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// 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?
}



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)
}

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: URLStringConvertible = "http://raw.githubusercontent.com/evermeer/AlamofireXmlToObjects/master/AlamofireXmlToObjectsTests/sample3_xml"
let expectation = expectationWithDescription("\(URL)")

Alamofire.request(.GET, URL)
.responseObject { (response: Result<AllGames, NSError>) in

expectation.fulfill()
if let error = response.error {
XCTAssert(false, "ERROR: \(error.description)")
} else {
if let result = response.value {
print("\(result.description)")

} else {
XCTAssert(false, "no result from service")
}
}


}

waitForExpectationsWithTimeout(10, handler: { (error: NSError?) -> Void in
XCTAssertNil(error, "\(error)")
})
}

}
48 changes: 48 additions & 0 deletions AlamofireXmlToObjectsTests/sample3_xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<allgames>
<StateProv stateprov_name="Arkansas" stateprov_id="AR">
<game game_id="101" game_name="Powerball" update_time="WED 2016-06-01 23:00:34 EST">
<lastdraw_date>06/01/2016</lastdraw_date>
<lastdraw_numbers>23-30-33-40-69, Powerball: 12, Power Play: 5</lastdraw_numbers>
<nextdraw_date>06/04/2016</nextdraw_date>
<jackpot date="06/04/2016">110000000</jackpot>
</game>
<game game_id="113" game_name="MEGA Millions" update_time="FRI 2016-06-03 23:01:31 EST">
<lastdraw_date>06/03/2016</lastdraw_date>
<lastdraw_numbers>32-54-65-66-71, Mega Ball: 10, Megaplier: 3</lastdraw_numbers>
<nextdraw_date>06/07/2016</nextdraw_date>
<jackpot date="06/03/2016">251000000</jackpot>
</game>
<game game_id="132" game_name="Lucky For Life" update_time="THU 2016-06-02 22:54:02 EST">
<lastdraw_date>06/02/2016</lastdraw_date>
<lastdraw_numbers>11-19-36-37-42, Lucky Ball: 10</lastdraw_numbers>
<nextdraw_date>06/06/2016</nextdraw_date>
</game>
<game game_id="AR1" game_name="Natural State Jackpot" update_time="FRI 2016-06-03 21:19:03 EST">
<lastdraw_date>06/03/2016</lastdraw_date>
<lastdraw_numbers>04-18-19-21-33</lastdraw_numbers>
<nextdraw_date>06/04/2016</nextdraw_date>
<jackpot date="06/04/2016">105000</jackpot>
</game>
<game game_id="ARD" game_name="Cash 4 Midday" update_time="FRI 2016-06-03 14:10:03 EST">
<lastdraw_date>06/03/2016</lastdraw_date>
<lastdraw_numbers>6-0-8-3</lastdraw_numbers>
<nextdraw_date>06/04/2016</nextdraw_date>
</game>
<game game_id="ARB" game_name="Cash 3 Midday" update_time="FRI 2016-06-03 14:09:03 EST">
<lastdraw_date>06/03/2016</lastdraw_date>
<lastdraw_numbers>4-7-4</lastdraw_numbers>
<nextdraw_date>06/04/2016</nextdraw_date>
</game>
<game game_id="ARC" game_name="Cash 4 Evening" update_time="FRI 2016-06-03 20:10:02 EST">
<lastdraw_date>06/03/2016</lastdraw_date>
<lastdraw_numbers>2-6-4-1</lastdraw_numbers>
<nextdraw_date>06/04/2016</nextdraw_date>
</game>
<game game_id="ARA" game_name="Cash 3 Evening" update_time="FRI 2016-06-03 20:12:12 EST">
<lastdraw_date>06/03/2016</lastdraw_date>
<lastdraw_numbers>5-2-0</lastdraw_numbers>
<nextdraw_date>06/04/2016</nextdraw_date>
</game>
</StateProv>
</allgames>

0 comments on commit a0e0f2c

Please sign in to comment.