mirror of
https://github.com/ysoftdevs/Theatrical-Players-Refactoring-Kata.git
synced 2026-01-11 22:30:27 +01:00
converted kata to swift
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,100 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1030"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "104F7D7323282F2900665957"
|
||||||
|
BuildableName = "Theatrical_Players_Refactoring_Kata.framework"
|
||||||
|
BlueprintName = "Theatrical-Players-Refactoring-Kata"
|
||||||
|
ReferencedContainer = "container:Theatrical-Players-Refactoring-Kata.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
codeCoverageEnabled = "YES"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "104F7D7C23282F2900665957"
|
||||||
|
BuildableName = "Theatrical-Players-Refactoring-KataTests.xctest"
|
||||||
|
BlueprintName = "Theatrical-Players-Refactoring-KataTests"
|
||||||
|
ReferencedContainer = "container:Theatrical-Players-Refactoring-Kata.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "104F7D7323282F2900665957"
|
||||||
|
BuildableName = "Theatrical_Players_Refactoring_Kata.framework"
|
||||||
|
BlueprintName = "Theatrical-Players-Refactoring-Kata"
|
||||||
|
ReferencedContainer = "container:Theatrical-Players-Refactoring-Kata.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "104F7D7323282F2900665957"
|
||||||
|
BuildableName = "Theatrical_Players_Refactoring_Kata.framework"
|
||||||
|
BlueprintName = "Theatrical-Players-Refactoring-Kata"
|
||||||
|
ReferencedContainer = "container:Theatrical-Players-Refactoring-Kata.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "104F7D7323282F2900665957"
|
||||||
|
BuildableName = "Theatrical_Players_Refactoring_Kata.framework"
|
||||||
|
BlueprintName = "Theatrical-Players-Refactoring-Kata"
|
||||||
|
ReferencedContainer = "container:Theatrical-Players-Refactoring-Kata.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -10,5 +10,18 @@
|
|||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
<dict>
|
||||||
|
<key>104F7D7323282F2900665957</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>104F7D7C23282F2900665957</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
struct Invoice {
|
struct Invoice {
|
||||||
let customer: String
|
let customer: String
|
||||||
let performances: [Performance]
|
let performances: [Performance]
|
||||||
init(_ customer: String, _ performances: Array<Performance>) {
|
|
||||||
self.customer = customer
|
|
||||||
self.performances = performances
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
struct Performance {
|
struct Performance {
|
||||||
let playID: String
|
let playID: String
|
||||||
let audience: Int
|
let audience: Int
|
||||||
init(_ playID: String, _ audience: Int) {
|
|
||||||
self.playID = playID
|
|
||||||
self.audience = audience
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
struct Play {
|
struct Play {
|
||||||
let name, type: String
|
let name, type: String
|
||||||
init(_ name: String, _ type: String) {
|
|
||||||
self.name = name
|
|
||||||
self.type = type
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,5 +52,3 @@ class StatementPrinter {
|
|||||||
enum UnknownTypeError: Error {
|
enum UnknownTypeError: Error {
|
||||||
case unknownTypeError(String)
|
case unknownTypeError(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: get test to pass and coverage, destructure performance object in for loop
|
|
||||||
|
|||||||
@@ -7,43 +7,44 @@ class StatementPrinterTests: XCTestCase {
|
|||||||
|
|
||||||
let expected = """
|
let expected = """
|
||||||
Statement for BigCo
|
Statement for BigCo
|
||||||
Hamlet: $650.00 (55 seats)
|
Hamlet: $650.00 (55 seats)
|
||||||
As You Like It: $580.00 (35 seats)
|
As You Like It: $580.00 (35 seats)
|
||||||
Othello: $500.00 (40 seats)
|
Othello: $500.00 (40 seats)
|
||||||
Amount owed is $1,730.00
|
Amount owed is $1,730.00
|
||||||
You earned 47 credits
|
You earned 47 credits
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
let plays = [
|
let plays = [
|
||||||
"hamlet": Play("Hamlet", "tragedy"),
|
"hamlet": Play(name: "Hamlet", type: "tragedy"),
|
||||||
"as-like": Play("As You Like It", "comedy"),
|
"as-like": Play(name: "As You Like It", type: "comedy"),
|
||||||
"othello": Play("Othello", "tragedy")
|
"othello": Play(name: "Othello", type: "tragedy")
|
||||||
]
|
]
|
||||||
|
|
||||||
let invoice = Invoice(
|
let invoice = Invoice(
|
||||||
"BigCo", [
|
customer: "BigCo", performances: [
|
||||||
Performance("hamlet", 55),
|
Performance(playID: "hamlet", audience: 55),
|
||||||
Performance("as-like", 35),
|
Performance(playID: "as-like", audience: 35),
|
||||||
Performance("othello", 40)
|
Performance(playID: "othello", audience: 40)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
let statementPrinter = StatementPrinter()
|
let statementPrinter = StatementPrinter()
|
||||||
let result = try statementPrinter.print(invoice, plays)
|
let result = try statementPrinter.print(invoice, plays)
|
||||||
|
|
||||||
XCTAssertEqual(expected, result)
|
XCTAssertEqual(result, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_statementWithNewPlayTypes() {
|
func test_statementWithNewPlayTypes() {
|
||||||
let plays = [
|
let plays = [
|
||||||
"henry-v": Play("Henry V", "history"),
|
"henry-v": Play(name: "Henry V", type: "history"),
|
||||||
"as-like": Play("As You Like It", "pastoral")
|
"as-like": Play(name: "As You Like It", type: "pastoral")
|
||||||
]
|
]
|
||||||
|
|
||||||
let invoice = Invoice(
|
let invoice = Invoice(
|
||||||
"BigCo", [
|
customer: "BigCo", performances: [
|
||||||
Performance("henry-v", 53),
|
Performance(playID: "henry-v", audience: 53),
|
||||||
Performance("as-like", 55)
|
Performance(playID: "as-like", audience: 55)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user