From 4180ecf6d5ef346d7c8b2f602899f1ccd3b16a0d Mon Sep 17 00:00:00 2001 From: masakih Date: Sun, 3 Dec 2017 14:48:53 +0900 Subject: [PATCH] =?utf8?q?=E5=BE=85=E9=81=BF=E3=81=AE=E3=83=86=E3=82=B9?= =?utf8?q?=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KCD.xcodeproj/project.pbxproj | 4 +++ KCDTests/GuardEscapeTest.swift | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 KCDTests/GuardEscapeTest.swift diff --git a/KCD.xcodeproj/project.pbxproj b/KCD.xcodeproj/project.pbxproj index 9bfb4dac..d4283790 100644 --- a/KCD.xcodeproj/project.pbxproj +++ b/KCD.xcodeproj/project.pbxproj @@ -272,6 +272,7 @@ F4CB371D1FCC5FCC0086999C /* CombinedBattleTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4CB371C1FCC5FCC0086999C /* CombinedBattleTest.swift */; }; F4CB37201FD046E10086999C /* BattleInformationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4CB371E1FD046E10086999C /* BattleInformationViewController.swift */; }; F4CB37211FD046E10086999C /* BattleInformationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4CB371F1FD046E10086999C /* BattleInformationViewController.xib */; }; + F4CB37291FD3C1A00086999C /* GuardEscapeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4CB37281FD3C1A00086999C /* GuardEscapeTest.swift */; }; F4CC5C091F88DBD50006B3FA /* NSPredicateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4CC5C081F88DBD50006B3FA /* NSPredicateExtension.swift */; }; F4CF25A81E325ABA00C02A66 /* APIResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4CF25A71E325ABA00C02A66 /* APIResponse.swift */; }; F4CF25AA1E338ED000C02A66 /* JSONTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4CF25A91E338ED000C02A66 /* JSONTracker.swift */; }; @@ -638,6 +639,7 @@ F4CB371C1FCC5FCC0086999C /* CombinedBattleTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CombinedBattleTest.swift; sourceTree = ""; }; F4CB371E1FD046E10086999C /* BattleInformationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BattleInformationViewController.swift; sourceTree = ""; }; F4CB371F1FD046E10086999C /* BattleInformationViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BattleInformationViewController.xib; sourceTree = ""; }; + F4CB37281FD3C1A00086999C /* GuardEscapeTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuardEscapeTest.swift; sourceTree = ""; }; F4CC5C081F88DBD50006B3FA /* NSPredicateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSPredicateExtension.swift; sourceTree = ""; }; F4CF25A71E325ABA00C02A66 /* APIResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = APIResponse.swift; sourceTree = ""; }; F4CF25A91E338ED000C02A66 /* JSONTracker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONTracker.swift; sourceTree = ""; }; @@ -1096,6 +1098,7 @@ F4FF44C61F98DA6600039F21 /* NormalBattleTest.swift */, F4CB371C1FCC5FCC0086999C /* CombinedBattleTest.swift */, F4FF44CB1F9E41F600039F21 /* ShipStatusTest.swift */, + F4CB37281FD3C1A00086999C /* GuardEscapeTest.swift */, ); path = KCDTests; sourceTree = ""; @@ -1855,6 +1858,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + F4CB37291FD3C1A00086999C /* GuardEscapeTest.swift in Sources */, F4CB371D1FCC5FCC0086999C /* CombinedBattleTest.swift in Sources */, F4FF44C71F98DA6600039F21 /* NormalBattleTest.swift in Sources */, F4FF44CC1F9E41F600039F21 /* ShipStatusTest.swift in Sources */, diff --git a/KCDTests/GuardEscapeTest.swift b/KCDTests/GuardEscapeTest.swift new file mode 100644 index 00000000..b7a2881d --- /dev/null +++ b/KCDTests/GuardEscapeTest.swift @@ -0,0 +1,56 @@ +// +// GuardEscapeTest.swift +// KCDTests +// +// Created by Hori,Masaki on 2017/12/03. +// Copyright © 2017年 Hori,Masaki. All rights reserved. +// + +import XCTest + +@testable import KCD + + +class GuardEscapeTest: XCTestCase { + + override func setUp() { + super.setUp() + + let store = TemporaryDataStore.oneTimeEditor() + store.guardEscaped().forEach(store.delete) + } + + override func tearDown() { + + let store = TemporaryDataStore.oneTimeEditor() + store.guardEscaped().forEach(store.delete) + super.tearDown() + } + + func testShipEntity() { + + let shipId = 5225 + let serverStore = ServerDataStore.default + + guard let ship = serverStore.ship(by: shipId) else { + XCTFail("can not get Ship id \(shipId)") + return + } + + XCTAssertFalse(ship.guardEscaped) + + let tempStore = TemporaryDataStore.oneTimeEditor() + guard let g = tempStore.createGuardEscaped() else { + XCTFail("can not create GuardEscaped") + return + } + + g.shipID = shipId + g.ensured = true + + try? tempStore.save() + + XCTAssertTrue(ship.guardEscaped) + } + +} -- 2.11.0