• R/O
  • HTTP
  • SSH
  • HTTPS

KCD: コミット

main code repository.


コミットメタ情報

リビジョン36288547234653d1f048387bf221101d65abd389 (tree)
日時2017-10-23 00:20:33
作者masakih <masakih@user...>
コミッターmasakih

ログメッセージ

テストを一つにまとめた

変更サマリ

差分

--- a/KCD.xcodeproj/project.pbxproj
+++ b/KCD.xcodeproj/project.pbxproj
@@ -317,9 +317,8 @@
317317 F4FC3E901E437E1F00E41228 /* JSONReciever.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FC3E8F1E437E1F00E41228 /* JSONReciever.swift */; };
318318 F4FC3E941E44A5D600E41228 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FC3E931E44A5D600E41228 /* AppDelegate.swift */; };
319319 F4FC3E961E46AC3000E41228 /* TSVSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FC3E951E46AC3000E41228 /* TSVSupport.swift */; };
320- F4FF44C71F98DA6600039F21 /* NormalBattleAPIsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF44C61F98DA6600039F21 /* NormalBattleAPIsTest.swift */; };
320+ F4FF44C71F98DA6600039F21 /* NormalBattleTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF44C61F98DA6600039F21 /* NormalBattleTest.swift */; };
321321 F4FF44C81F98DB1D00039F21 /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4EFBCA21E7D439A00DE4A58 /* SwiftyJSON.framework */; };
322- F4FF44CA1F9CB39000039F21 /* SecondFleetBattleTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF44C91F9CB39000039F21 /* SecondFleetBattleTest.swift */; };
323322 /* End PBXBuildFile section */
324323
325324 /* Begin PBXContainerItemProxy section */
@@ -695,8 +694,7 @@
695694 F4FC3E8F1E437E1F00E41228 /* JSONReciever.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONReciever.swift; sourceTree = "<group>"; };
696695 F4FC3E931E44A5D600E41228 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
697696 F4FC3E951E46AC3000E41228 /* TSVSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TSVSupport.swift; sourceTree = "<group>"; };
698- F4FF44C61F98DA6600039F21 /* NormalBattleAPIsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NormalBattleAPIsTest.swift; sourceTree = "<group>"; };
699- F4FF44C91F9CB39000039F21 /* SecondFleetBattleTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondFleetBattleTest.swift; sourceTree = "<group>"; };
697+ F4FF44C61F98DA6600039F21 /* NormalBattleTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NormalBattleTest.swift; sourceTree = "<group>"; };
700698 /* End PBXFileReference section */
701699
702700 /* Begin PBXFrameworksBuildPhase section */
@@ -1041,8 +1039,7 @@
10411039 isa = PBXGroup;
10421040 children = (
10431041 F4BDEB6B187252F30069D0CE /* Supporting Files */,
1044- F4FF44C61F98DA6600039F21 /* NormalBattleAPIsTest.swift */,
1045- F4FF44C91F9CB39000039F21 /* SecondFleetBattleTest.swift */,
1042+ F4FF44C61F98DA6600039F21 /* NormalBattleTest.swift */,
10461043 );
10471044 path = KCDTests;
10481045 sourceTree = "<group>";
@@ -1781,8 +1778,7 @@
17811778 isa = PBXSourcesBuildPhase;
17821779 buildActionMask = 2147483647;
17831780 files = (
1784- F4FF44CA1F9CB39000039F21 /* SecondFleetBattleTest.swift in Sources */,
1785- F4FF44C71F98DA6600039F21 /* NormalBattleAPIsTest.swift in Sources */,
1781+ F4FF44C71F98DA6600039F21 /* NormalBattleTest.swift in Sources */,
17861782 );
17871783 runOnlyForDeploymentPostprocessing = 0;
17881784 };
--- a/KCDTests/NormalBattleAPIsTest.swift
+++ /dev/null
@@ -1,282 +0,0 @@
1-//
2-// NormalBattleAPIsTest.swift
3-// KCDTests
4-//
5-// Created by Hori,Masaki on 2017/10/19.
6-// Copyright © 2017年 Hori,Masaki. All rights reserved.
7-//
8-
9-import XCTest
10-
11-@testable import KCD
12-
13-import SwiftyJSON
14-
15-class NormalBattleAPIsTest: XCTestCase {
16-
17- var savedShips: [Ship] = []
18- var shipsHp: [Int] = []
19- var shipEquipments: [NSOrderedSet] = []
20- var shipExSlot: [Int] = []
21-
22- override func setUp() {
23-
24- super.setUp()
25-
26- savedShips = []
27- shipsHp = []
28- shipEquipments = []
29- shipExSlot = []
30-
31- // 艦隊を設定
32- do {
33- let store = ServerDataStore.oneTimeEditor()
34- guard let deck = store.deck(by: 1) else { return XCTFail("Can not get Deck.") }
35- (0...5).forEach { deck.setShip(id: $0 + 1, for: $0) }
36-
37- store.ships(byDeckId: 1).forEach {
38- $0.nowhp = $0.maxhp
39-
40- savedShips += [$0]
41- shipsHp += [$0.nowhp]
42- shipEquipments += [$0.equippedItem]
43- shipExSlot += [$0.slot_ex]
44- }
45- }
46-
47- // 出撃艦隊を設定
48- do {
49- let rawValue: [String: Any] = [
50- "api_result": 1,
51- "api_data": [
52- "api_no": 1
53- ]
54- ]
55- guard let json = JSON(rawValue: rawValue) else { return XCTFail("json is nil") }
56- XCTAssertNotNil(json["api_result"])
57-
58- let paramValue: [String: String] = [
59- "api_deck_id": "1",
60- "api_maparea_id": "1",
61- "api_mapinfo_no": "1"
62- ]
63- let param = Parameter(paramValue)
64- XCTAssertEqual(param["api_deck_id"].string, "1")
65-
66- let api = APIResponse(api: MapAPI.start.rawValue, parameter: param, json: json)
67- XCTAssertEqual(api.json, json)
68- XCTAssertEqual(api.parameter, param)
69-
70- let command = MapStartCommand(apiResponse: api)
71-
72- command.execute()
73- }
74-
75- // battleの生成確認
76- do {
77- let store = TemporaryDataStore.default
78- let battle = store.battle()
79- XCTAssertNotNil(battle)
80- }
81- }
82-
83- override func tearDown() {
84-
85- do {
86- ResetSortie().reset()
87- }
88-
89- do {
90- let store = TemporaryDataStore.default
91- let battle = store.battle()
92- XCTAssertNil(battle)
93- }
94-
95- do {
96- let store = ServerDataStore.oneTimeEditor()
97-
98- let ships = store.ships(byDeckId: 1)
99-
100- zip(ships, shipsHp).forEach { $0.nowhp = $1 }
101- zip(ships, shipEquipments).forEach { $0.equippedItem = $1 }
102- zip(ships, shipExSlot).forEach { $0.slot_ex = $1 }
103-
104- guard let deck = store.deck(by: 1) else { return XCTFail("Can not get Deck.") }
105- savedShips.enumerated().forEach { deck.setShip(id: $0.element.id, for: $0.offset) }
106- }
107- super.tearDown()
108- }
109-
110- func testNormalBattle() {
111-
112- // 戦闘(昼戦)
113- do {
114- let rawValue: [String: Any] = [
115- "api_result": 1,
116- "api_data": [
117- "api_kouku": [
118- "api_stage3": [
119- "api_fdam": [
120- -1, 3, 0, 0, 0, 0, 0
121- ]
122- ]
123- ],
124- "api_opening_atack": [
125- "api_fdam": [
126- -1, 0, 3, 0, 0, 0, 0
127- ]
128- ],
129- "api_hougeki1": [
130- "api_df_list": [
131- -1,
132- [3, 3]
133- ],
134- "api_damage": [
135- -1,
136- [0, 1]
137- ]
138- ],
139- "api_raigeki": [
140- "api_fdam": [
141- -1, 0, 0, 0, 1, 0, 0
142- ]
143- ]
144- ]
145- ]
146- guard let json = JSON(rawValue: rawValue) else { return XCTFail("json is nil") }
147- let param = Parameter(["Test": "Test"])
148- let api = APIResponse(api: BattleAPI.battle.rawValue, parameter: param, json: json)
149-
150- let command = BattleCommand(apiResponse: api)
151- command.execute()
152- }
153-
154- // 戦闘(夜戦)
155- do {
156- let rawValue: [String: Any] = [
157- "api_result": 1,
158- "api_data": [
159- "api_hougeki": [
160- "api_df_list": [
161- -1,
162- [5]
163- ],
164- "api_damage": [
165- -1,
166- [5]
167- ]
168- ]
169- ]
170- ]
171- guard let json = JSON(rawValue: rawValue) else { return XCTFail("json is nil") }
172- let param = Parameter(["Test": "Test"])
173- let api = APIResponse(api: BattleAPI.midnightBattle.rawValue, parameter: param, json: json)
174-
175- let command = BattleCommand(apiResponse: api)
176- command.execute()
177- }
178-
179- // 艦娘HP更新
180- do {
181- let rawValue: [String: Any] = [
182- "api_result": 1
183- ]
184- guard let json = JSON(rawValue: rawValue) else { return XCTFail("json is nil") }
185- let param = Parameter(["Test": "Test"])
186- let api = APIResponse(api: BattleAPI.battleResult.rawValue, parameter: param, json: json)
187-
188- let command = BattleCommand(apiResponse: api)
189- command.execute()
190- }
191-
192- // HPチェック
193- do {
194- let store = ServerDataStore.oneTimeEditor()
195- let ships = store.ships(byDeckId: 1)
196-
197- XCTAssertEqual(ships.count, 6)
198-
199- XCTAssertEqual(ships[0].nowhp, shipsHp[0] - 3)
200- XCTAssertEqual(ships[1].nowhp, shipsHp[1] - 3)
201- XCTAssertEqual(ships[2].nowhp, shipsHp[2] - 1)
202- XCTAssertEqual(ships[3].nowhp, shipsHp[3] - 1)
203- XCTAssertEqual(ships[4].nowhp, shipsHp[4] - 5)
204- XCTAssertEqual(ships[5].nowhp, shipsHp[5])
205- }
206- }
207-
208- func testDamageControl() {
209-
210- // ダメコンを設定
211- do {
212- let store = ServerDataStore.oneTimeEditor()
213-
214- store.ship(by: 5).flatMap {
215- $0.nowhp = $0.maxhp
216- $0.slot_ex = 63765 // 女神
217- }
218- store.ship(by: 6).flatMap {
219- $0.nowhp = $0.maxhp
220- // ダメコン
221- $0.equippedItem = store.slotItem(by: 72418).map { NSOrderedSet(array: [$0]) } ?? []
222- }
223- }
224-
225- // 戦闘(夜戦)
226- do {
227- let rawValue: [String: Any] = [
228- "api_result": 1,
229- "api_data": [
230- "api_hougeki": [
231- "api_df_list": [
232- -1,
233- [4],
234- [5],
235- [6]
236- ],
237- "api_damage": [
238- -1,
239- [50],
240- [50],
241- [50]
242- ]
243- ]
244- ]
245- ]
246- guard let json = JSON(rawValue: rawValue) else { return XCTFail("json is nil") }
247- let param = Parameter(["Test": "Test"])
248- let api = APIResponse(api: BattleAPI.midnightBattle.rawValue, parameter: param, json: json)
249-
250- let command = BattleCommand(apiResponse: api)
251- command.execute()
252- }
253-
254- // 艦娘HP更新
255- do {
256- let rawValue: [String: Any] = [
257- "api_result": 1
258- ]
259- guard let json = JSON(rawValue: rawValue) else { return XCTFail("json is nil") }
260- let param = Parameter(["Test": "Test"])
261- let api = APIResponse(api: BattleAPI.battleResult.rawValue, parameter: param, json: json)
262-
263- let command = BattleCommand(apiResponse: api)
264- command.execute()
265- }
266-
267- // HPチェック
268- do {
269- let store = ServerDataStore.oneTimeEditor()
270- let ships = store.ships(byDeckId: 1)
271-
272- XCTAssertEqual(ships.count, 6)
273-
274- XCTAssertEqual(ships[0].nowhp, shipsHp[0])
275- XCTAssertEqual(ships[1].nowhp, shipsHp[1])
276- XCTAssertEqual(ships[2].nowhp, shipsHp[2])
277- XCTAssertEqual(ships[3].nowhp, 0)
278- XCTAssertEqual(ships[4].nowhp, shipsHp[4])
279- XCTAssertEqual(ships[5].nowhp, Int(Double(shipsHp[5]) * 0.2))
280- }
281- }
282-}
--- a/KCDTests/SecondFleetBattleTest.swift
+++ b/KCDTests/NormalBattleTest.swift
@@ -1,8 +1,8 @@
11 //
2-// SecondFleetBattleTest.swift
2+// NormalBattleTest.swift
33 // KCDTests
44 //
5-// Created by Hori,Masaki on 2017/10/22.
5+// Created by Hori,Masaki on 2017/10/19.
66 // Copyright © 2017年 Hori,Masaki. All rights reserved.
77 //
88
@@ -12,18 +12,14 @@ import XCTest
1212
1313 import SwiftyJSON
1414
15-class SecondFleetBattleTest: XCTestCase {
15+class NormalBattleTest: XCTestCase {
1616
1717 var savedShips: [Ship] = []
1818 var shipsHp: [Int] = []
1919 var shipEquipments: [NSOrderedSet] = []
2020 var shipExSlot: [Int] = []
2121
22- let deckId = 2
23-
24- override func setUp() {
25-
26- super.setUp()
22+ func initBattleFleet(_ fleet: Int) {
2723
2824 savedShips = []
2925 shipsHp = []
@@ -37,10 +33,10 @@ class SecondFleetBattleTest: XCTestCase {
3733 guard let secondFleet = store.deck(by: 2) else { return XCTFail("Can not get Deck.") }
3834 (0...5).forEach { secondFleet.setShip(id: $0 + 10, for: $0) }
3935
40- guard let deck = store.deck(by: deckId) else { return XCTFail("Can not get Deck.") }
36+ guard let deck = store.deck(by: fleet) else { return XCTFail("Can not get Deck.") }
4137 (0...5).forEach { deck.setShip(id: $0 + 1, for: $0) }
4238
43- store.ships(byDeckId: deckId).forEach {
39+ store.ships(byDeckId: fleet).forEach {
4440 $0.nowhp = $0.maxhp
4541
4642 savedShips += [$0]
@@ -62,12 +58,12 @@ class SecondFleetBattleTest: XCTestCase {
6258 XCTAssertNotNil(json["api_result"])
6359
6460 let paramValue: [String: String] = [
65- "api_deck_id": "\(deckId)",
61+ "api_deck_id": "\(fleet)",
6662 "api_maparea_id": "1",
6763 "api_mapinfo_no": "1"
6864 ]
6965 let param = Parameter(paramValue)
70- XCTAssertEqual(param["api_deck_id"].string, "\(deckId)")
66+ XCTAssertEqual(param["api_deck_id"].string, "\(fleet)")
7167
7268 let api = APIResponse(api: MapAPI.start.rawValue, parameter: param, json: json)
7369 XCTAssertEqual(api.json, json)
@@ -83,11 +79,11 @@ class SecondFleetBattleTest: XCTestCase {
8379 let store = TemporaryDataStore.default
8480 let battle = store.battle()
8581 XCTAssertNotNil(battle)
86- XCTAssertEqual(battle?.deckId, deckId)
82+ XCTAssertEqual(battle?.deckId, fleet)
8783 }
8884 }
8985
90- override func tearDown() {
86+ func clear(_ fleet: Int) {
9187
9288 do {
9389 ResetSortie().reset()
@@ -102,19 +98,18 @@ class SecondFleetBattleTest: XCTestCase {
10298 do {
10399 let store = ServerDataStore.oneTimeEditor()
104100
105- let ships = store.ships(byDeckId: deckId)
101+ let ships = store.ships(byDeckId: fleet)
106102
107103 zip(ships, shipsHp).forEach { $0.nowhp = $1 }
108104 zip(ships, shipEquipments).forEach { $0.equippedItem = $1 }
109105 zip(ships, shipExSlot).forEach { $0.slot_ex = $1 }
110106
111- guard let deck = store.deck(by: deckId) else { return XCTFail("Can not get Deck.") }
107+ guard let deck = store.deck(by: fleet) else { return XCTFail("Can not get Deck.") }
112108 savedShips.enumerated().forEach { deck.setShip(id: $0.element.id, for: $0.offset) }
113109 }
114- super.tearDown()
115110 }
116111
117- func testNormalBattle() {
112+ func normalBattle(_ fleet: Int) {
118113
119114 // 戦闘(昼戦)
120115 do {
@@ -199,7 +194,7 @@ class SecondFleetBattleTest: XCTestCase {
199194 // HPチェック
200195 do {
201196 let store = ServerDataStore.oneTimeEditor()
202- let ships = store.ships(byDeckId: deckId)
197+ let ships = store.ships(byDeckId: fleet)
203198
204199 XCTAssertEqual(ships.count, 6)
205200
@@ -212,7 +207,7 @@ class SecondFleetBattleTest: XCTestCase {
212207 }
213208 }
214209
215- func testDamageControl() {
210+ func damageControl(_ fleet: Int) {
216211
217212 // ダメコンを設定
218213 do {
@@ -274,7 +269,7 @@ class SecondFleetBattleTest: XCTestCase {
274269 // HPチェック
275270 do {
276271 let store = ServerDataStore.oneTimeEditor()
277- let ships = store.ships(byDeckId: deckId)
272+ let ships = store.ships(byDeckId: fleet)
278273
279274 XCTAssertEqual(ships.count, 6)
280275
@@ -286,4 +281,37 @@ class SecondFleetBattleTest: XCTestCase {
286281 XCTAssertEqual(ships[5].nowhp, Int(Double(shipsHp[5]) * 0.2))
287282 }
288283 }
284+
285+ func testFirstFleet() {
286+
287+ initBattleFleet(1)
288+ normalBattle(1)
289+ initBattleFleet(1)
290+ damageControl(1)
291+ clear(1)
292+ }
293+ func testSecondFleet() {
294+
295+ initBattleFleet(2)
296+ normalBattle(2)
297+ initBattleFleet(2)
298+ damageControl(2)
299+ clear(2)
300+ }
301+ func testThiredFleet() {
302+
303+ initBattleFleet(3)
304+ normalBattle(3)
305+ initBattleFleet(3)
306+ damageControl(3)
307+ clear(3)
308+ }
309+ func testFourthFleet() {
310+
311+ initBattleFleet(4)
312+ normalBattle(4)
313+ initBattleFleet(4)
314+ damageControl(4)
315+ clear(4)
316+ }
289317 }
旧リポジトリブラウザで表示