Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

은행창구 관리 앱 [Step3] Harry #101

Open
wants to merge 1 commit into
base: d_Harry
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
7 changes: 0 additions & 7 deletions BankManager.swift

This file was deleted.

Binary file added BankManagerConsoleApp/.DS_Store
Binary file not shown.
235 changes: 230 additions & 5 deletions BankManagerConsoleApp/BankManagerConsoleApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
version = "2.2">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<AutocreatedTestPlanReference>
</AutocreatedTestPlanReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9B7373062B61325300FDB082"
BuildableName = "BankManagerConsoleTests.xctest"
BlueprintName = "BankManagerConsoleTests"
ReferencedContainer = "container:BankManagerConsoleApp.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</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">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9B7373062B61325300FDB082"
BuildableName = "BankManagerConsoleTests.xctest"
BlueprintName = "BankManagerConsoleTests"
ReferencedContainer = "container:BankManagerConsoleApp.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
3 changes: 2 additions & 1 deletion BankManagerConsoleApp/BankManagerConsoleApp/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
// Copyright © yagom academy. All rights reserved.
//

import Foundation
var console: ConsoleManager = ConsoleManager()
console.operate()
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

import XCTest
@testable import BankManagerConsoleApp

final class BankMangerLinkedListTests: XCTestCase {
var sutLinkedTest: LinkedList<String>!

override func setUpWithError() throws {
sutLinkedTest = LinkedList()
}

override func tearDownWithError() throws {
sutLinkedTest = nil
}

func test_입력이1개일때_노드를1개추가하고삭제를1번하면_입력한노드가없을것이다() {
// given
let input = "A"
// when
sutLinkedTest.appendNodeAtRear(with: input)
let _ = sutLinkedTest.removeNodeFromFront()
let result = sutLinkedTest.searchNodeLocation(with: input)
// then
XCTAssertNil(result)
}

func test_입력이1개일때_노드를1개추가하고그값을조회하면_1번위치가반환된다() {
// given
let input = "A"
let expectedResult = 1
// when
sutLinkedTest.appendNodeAtRear(with: input)
let result = sutLinkedTest.searchNodeLocation(with: input)
// then
XCTAssertEqual(expectedResult, result)
}

func test_입력이3개일때_노드를3개추가하고3번째값을조회하면_3번위치가반환된다() {
// given
let input = [ "A", "B", "C" ]
let expectedResult = 3
// when
for data in input {
sutLinkedTest.appendNodeAtRear(with: data)
}
let result = sutLinkedTest.searchNodeLocation(with: input[2])
// then
XCTAssertEqual(expectedResult, result)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@

import XCTest
@testable import BankManagerConsoleApp

final class BankManagerQueueTests: XCTestCase {
var sut: Queue<String>!

override func setUpWithError() throws {
sut = Queue<String>()
}

override func tearDownWithError() throws {
sut = nil
}

func test_초기상태일때_대기열을확인하면_대기열이없을것이다() {
// given
// when
let result = sut.isEmpty
// then
XCTAssertTrue(result)
}

func test_입력이1개있을때_enqueue를수행하면_대기열이있을것이다() {
// given
let input = "test"
// when
sut.enqueue(with: input)
let result = sut.isEmpty
// then
XCTAssertFalse(result)
}

func test_입력이5개있을때_queue의길이를확인하면_길이가5일것이다() {
// given
let data = [ "A", "B", "C", "D", "E" ]
let expectedLengthOfQueue = 5
// when
for input in data {
sut.enqueue(with: input)
}
let result = sut.totalLength()
// then
XCTAssertEqual(expectedLengthOfQueue, result)
}

func test_입력이5개일때_enqueue를5번dequeue를4번하면_queue의길이가1일것이다() {
// given
let data = [ "A", "B", "C", "D", "E" ]
let lengthOfQueue = 1
let countOfDeque = 4
// when
for input in data {
sut.enqueue(with: input)
}
for _ in 1...countOfDeque {
let _ = sut.dequeue()
}
let result = sut.totalLength()
// then
XCTAssertEqual(lengthOfQueue, result)
}

func test_입력이5개일때_enqueue를5번dequeue3번하면_4번째데이터를정상적으로peek한다() {
// given
let data = [ "A", "B", "C", "D", "E" ]
let countOfDeque = 3
let expectedResult = data[countOfDeque]
// when
for input in data {
sut.enqueue(with: input)
}
for _ in 1...countOfDeque {
let _ = sut.dequeue()
}
let result = sut.peek()
// then
XCTAssertEqual(expectedResult, result)
}

func test_초기상태일때_dequeue를1번수행하면_길이가0을유지한다() {
// given
let expectedCount = 0
// when
let _ = sut.dequeue()
let result = sut.totalLength()
// then
XCTAssertEqual(expectedCount, result)
}

func test_초기상태일때_dequeue를1번수행하면_가져오는것이없을것이다() {
// given
// when
let result = sut.dequeue()
// then
XCTAssertNil(result)
}

func test_입력이2개일때_enqueue를2번dequeue를1번수행하면_peek되는값이second일것이다() {
// given
let input = [ "First", "Second" ]
let expectedResult = "Second"
// when
for data in input {
sut.enqueue(with: data)
}
let _ = sut.dequeue()
let result = sut.peek()
// then
XCTAssertEqual(expectedResult, result)
}

func test_입력이2개일때_enqueue를2번수행하면_dequeue한값이First일것이다() {
// given
let input = [ "First", "Second" ]
let expectedResult = "First"
//when
for data in input {
sut.enqueue(with: data)
}
let result = sut.dequeue()
// then
XCTAssertEqual(expectedResult, result)
}

func test_입력이2개일때_enqueue를2번하고peek를하면_반환되는값이First일것이다() {
// given
let input = [ "First", "Second" ]
let expectedResult = "First"
// when
for data in input {
sut.enqueue(with: data)
}
let result = sut.peek()
// then
XCTAssertEqual(expectedResult, result)
}

func test_입력이4개일때_enqueue를4번하고clean을하면_대기열이없을것이다() {
// given
let input = [ "A", "B", "C", "D" ]
// when
for data in input {
sut.enqueue(with: data)
}
let _ = sut.clean()
let result = sut.isEmpty
// then
XCTAssertTrue(result)
}

func test_입력이3개일때_enque를3번하면_head의다음다음노드가정상연결되고데이터를불러온다() {
// given
let input = [ "A", "B", "C" ]
let expectedResult = "C"
// when
for data in input {
sut.enqueue(with: data)
}
let result = sut.linkedList.head?.next?.next?.data
// then
XCTAssertEqual(expectedResult, result)
}

func test_입력이3개일때_enqueue를3번하면_tail의다음연결이nil이다() {
// given
let input = [ "A", "B", "C" ]
// when
for data in input {
sut.enqueue(with: data)
}
let result = sut.linkedList.tail?.next
// then
XCTAssertNil(result)
}
}
Binary file added BankManagerConsoleApp/Controller/.DS_Store
Binary file not shown.
21 changes: 21 additions & 0 deletions BankManagerConsoleApp/Controller/BankManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// BankManager.swift
// Created by yagom.
// Copyright © yagom academy. All rights reserved.
//

import Foundation

struct BankManager {
private(set) var employees: [Employee]

init(employees: [Employee]) {
self.employees = employees
}

func reportDeadlineSummary(with customerNumber: Int, startTime bankingServiceStart: TimeInterval, endTime bankingServiceEnd: TimeInterval) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#90 (comment)
필요한 값이 아닌 인스턴스를 넘기게 되면 함수 내부에서는 인스턴스의 불필요한 정보까지 접근 가능하게 되는 측면이 있습니다.
함수의 형태를 좀 더 깔끔하게 유지시켜주기 위해 저는 필요한 값들만 따로 넘겨주도록 작성합니다 😄
(특정 인스턴스의 여러 값들에 접근해야 하는 경우는 또 생각해봐야겠죠??)

let totalTime = bankingServiceEnd - bankingServiceStart
let convertedTotalTime = String(format: "%.2f", totalTime)
print("업무가 마감되었습니다. 오늘 업무를 처리한 고객은 총 \(customerNumber)명이며, 총 업무시간은 \(convertedTotalTime) 입니다.")
}
}
Loading