diff --git a/MaxibonKataIOS.xcodeproj/project.pbxproj b/MaxibonKataIOS.xcodeproj/project.pbxproj index 2327a89..78e5a00 100644 --- a/MaxibonKataIOS.xcodeproj/project.pbxproj +++ b/MaxibonKataIOS.xcodeproj/project.pbxproj @@ -16,8 +16,6 @@ EBC26D151D24415F00838900 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EBC26D131D24415F00838900 /* LaunchScreen.storyboard */; }; EBC26D2D1D24422A00838900 /* Developer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBC26D2B1D24422A00838900 /* Developer.swift */; }; EBC26D2E1D24422A00838900 /* KarumiHQs.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBC26D2C1D24422A00838900 /* KarumiHQs.swift */; }; - EBC26D301D2442B100838900 /* KarumiHQsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBC26D2F1D2442B100838900 /* KarumiHQsSpec.swift */; }; - EBCD24241D24488C0007923F /* DeveloperSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBCD24231D24488C0007923F /* DeveloperSpec.swift */; }; EBCD24261D244F210007923F /* ArbitraryDeveloper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBCD24251D244F210007923F /* ArbitraryDeveloper.swift */; }; EBCD24291D2457380007923F /* Chat.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBCD24281D2457380007923F /* Chat.swift */; }; EBCD242B1D24575F0007923F /* Slack.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBCD242A1D24575F0007923F /* Slack.swift */; }; @@ -51,8 +49,6 @@ EBC26D211D24415F00838900 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; EBC26D2B1D24422A00838900 /* Developer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Developer.swift; sourceTree = ""; }; EBC26D2C1D24422A00838900 /* KarumiHQs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KarumiHQs.swift; sourceTree = ""; }; - EBC26D2F1D2442B100838900 /* KarumiHQsSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KarumiHQsSpec.swift; sourceTree = ""; }; - EBCD24231D24488C0007923F /* DeveloperSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeveloperSpec.swift; sourceTree = ""; }; EBCD24251D244F210007923F /* ArbitraryDeveloper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArbitraryDeveloper.swift; sourceTree = ""; }; EBCD24281D2457380007923F /* Chat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Chat.swift; sourceTree = ""; }; EBCD242A1D24575F0007923F /* Slack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Slack.swift; sourceTree = ""; }; @@ -137,8 +133,6 @@ EBC26D1E1D24415F00838900 /* MaxibonKataIOSTests */ = { isa = PBXGroup; children = ( - EBC26D2F1D2442B100838900 /* KarumiHQsSpec.swift */, - EBCD24231D24488C0007923F /* DeveloperSpec.swift */, EBCD242C1D24578C0007923F /* Test Doubles */, EBC26D311D24446700838900 /* Generators */, EBC26D211D24415F00838900 /* Info.plist */, @@ -360,8 +354,6 @@ files = ( EBCD24261D244F210007923F /* ArbitraryDeveloper.swift in Sources */, EBCD242E1D24579D0007923F /* MockSlack.swift in Sources */, - EBCD24241D24488C0007923F /* DeveloperSpec.swift in Sources */, - EBC26D301D2442B100838900 /* KarumiHQsSpec.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MaxibonKataIOSTests/DeveloperSpec.swift b/MaxibonKataIOSTests/DeveloperSpec.swift deleted file mode 100644 index b196298..0000000 --- a/MaxibonKataIOSTests/DeveloperSpec.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// DeveloperSpec.swift -// MaxibonKataIOS -// -// Created by Pedro Vicente Gomez on 29/06/16. -// Copyright © 2016 GoKarumi. All rights reserved. -// - -import Foundation -import XCTest -import SwiftCheck -@testable import MaxibonKataIOS - -class DeveloperSpec: XCTestCase { - - fileprivate let anyName = "Pedro" - fileprivate let anyNumberOfMaxibonsToGet = 11 - - func testTheNumberOfMaxibonsPerKarumieAre() { - XCTAssertEqual(3, Karumies.Pedro.numberOfMaxibonsToGet) - XCTAssertEqual(0, Karumies.Davide.numberOfMaxibonsToGet) - XCTAssertEqual(1, Karumies.Toni.numberOfMaxibonsToGet) - XCTAssertEqual(2, Karumies.Jorge.numberOfMaxibonsToGet) - XCTAssertEqual(1, Karumies.Sergio.numberOfMaxibonsToGet) - XCTAssertEqual(1, Karumies.Fran.numberOfMaxibonsToGet) - } - - func testAll() { - property("Number of maxibons to consume can not be negative") <- forAll { (developer: Developer) in - return developer.numberOfMaxibonsToGet >= 0 - } - - property("The number of maxibons is asigned if is positive or zero") - <- forAll { (positiveNumber: NonNegative) in - let numberOfMaxibons = positiveNumber.getNonNegative - let developer = Developer(name: self.anyName, numberOfMaxibonsToGet: numberOfMaxibons) - return developer.numberOfMaxibonsToGet == numberOfMaxibons - } - - property("The name is asigned in construction") <- forAll { (name: String) in - let developer = Developer(name: name, numberOfMaxibonsToGet: self.anyNumberOfMaxibonsToGet) - return developer.name == name - } - } - -} diff --git a/MaxibonKataIOSTests/KarumiHQsSpec.swift b/MaxibonKataIOSTests/KarumiHQsSpec.swift deleted file mode 100644 index 4b6d1b8..0000000 --- a/MaxibonKataIOSTests/KarumiHQsSpec.swift +++ /dev/null @@ -1,102 +0,0 @@ -// -// KarumiHQsSpec.swift -// MaxibonKataIOS -// -// Created by Pedro Vicente Gomez on 29/06/16. -// Copyright © 2016 GoKarumi. All rights reserved. -// - -import Foundation -import XCTest -import SwiftCheck -@testable import MaxibonKataIOS - -class KarumiHQsSpec: XCTestCase { - - func testKarumiHQsStartsTheWeekWithTenMaxibons() { - XCTAssertEqual(10, KarumiHQs().maxibonsLeft) - } - - func testAll() { - - property("The number of maxibons left can not be lower than two") - <- forAll { (developer: Developer) in - let karumiHQs = KarumiHQs() - karumiHQs.openFridge(developer) - return karumiHQs.maxibonsLeft > 2 - } - - property("If there are two or less maxibons pending after opening the fridge Karumi automatically buys 10 more") - <- forAll(Developer.arbitraryHungry) { (developer: Developer) in - let karumiHQs = KarumiHQs() - let initialMaxibons = karumiHQs.maxibonsLeft - let numOfMaxibons = developer.numberOfMaxibonsToGet - let expectedMaxibons = self.maxibonsAfterOpeningTheFridge(initialMaxibons, numOfMaxibons) - karumiHQs.openFridge(developer) - return karumiHQs.maxibonsLeft == expectedMaxibons - } - - property("If there are two or less maxibons after opening the fridge the developer sends a message to buy more") - <- forAll(Developer.arbitraryHungry) { (developer: Developer) in - let chat = MockChat() - let karumiHQs = KarumiHQs(chat: chat) - karumiHQs.openFridge(developer) - let expectedResult = chat.messageSent == "Hi guys, I'm \(developer). We need more maxibons!" - chat.messageSent = nil - return expectedResult - - } - - property("If there are more than two maxibons after opening the fridge the developer does not send any message") - <- forAll(Developer.arbitraryNotSoHungry) { (developer: Developer) in - let chat = MockChat() - let karumiHQs = KarumiHQs(chat: chat) - karumiHQs.openFridge(developer) - let expectedResult = chat.messageSent == nil - chat.messageSent = nil - return expectedResult - } - - property("If some Karumies go to the kitchen the number of maxibons left can't be lower than 2") - <- forAll { (developers: [Developer]) in - let karumiHQs = KarumiHQs() - karumiHQs.openFridge(developers) - return karumiHQs.maxibonsLeft > 2 - } - - property("If some Karumies go to the kitchen the number of maxibons left has to be correct") - <- forAll { (developers: [Developer]) in - let karumiHQs = KarumiHQs() - let initialMaxibons = karumiHQs.maxibonsLeft - let karumies = developers - karumiHQs.openFridge(karumies) - let expectedMaxibons = self.calculateMaxibonsLeft(initialMaxibons, developers: karumies) - return karumiHQs.maxibonsLeft == expectedMaxibons - } - - } - - fileprivate func calculateMaxibonsLeft(_ initialMaxibons: Int, developers: [Developer]) -> Int { - var maxibonsLeft = initialMaxibons - developers.forEach { developer in - maxibonsLeft -= developer.numberOfMaxibonsToGet - if maxibonsLeft < 0 { - maxibonsLeft = 0 - } - if maxibonsLeft <= 2 { - maxibonsLeft += 10 - } - } - return maxibonsLeft - } - - fileprivate func maxibonsAfterOpeningTheFridge(_ initialMaxibons: Int, _ maxibonsToGet: Int) -> Int { - var expectedMaxibons = initialMaxibons - maxibonsToGet - if expectedMaxibons < 0 { - expectedMaxibons = 0 - } - expectedMaxibons += 10 - return expectedMaxibons - } - -}