-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Unit test 통과 - FruitStoreError Error 프로토콜 제거
- Loading branch information
HJEHA
committed
Feb 16, 2022
1 parent
19577db
commit 4d80b27
Showing
5 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
import Foundation | ||
|
||
enum FruitStoreError: Error { | ||
enum FruitStoreError { | ||
case notEnoughFruits | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// JuiceMakerTests.swift | ||
// JuiceMakerTests | ||
// | ||
// Created by 황제하 on 2022/02/16. | ||
// | ||
|
||
import XCTest | ||
@testable import JuiceMaker | ||
|
||
private extension XCTestCase { | ||
func XCTSuccess() { | ||
XCTAssert(true) | ||
} | ||
} | ||
|
||
struct MockJuice: RecipeProtocol { | ||
var items: [FruitType : Int] | ||
} | ||
|
||
class JuiceMakerTests: XCTestCase { | ||
|
||
// MARK: - Test codes | ||
|
||
func test_인벤토리보다_적은과일쥬스를_만들었을때_성공을_반환하는가() { | ||
// given | ||
let fruitStore = FruitStore(initialFruitCount: 10) | ||
var juiceMaker = JuiceMaker(fruitStore: fruitStore) | ||
let input = MockJuice(items: [.banana: 5]) | ||
|
||
// when | ||
let writeResult = juiceMaker.make(with: input) | ||
|
||
// then | ||
switch writeResult { | ||
case .success(): | ||
XCTSuccess() | ||
case .failure(let error): | ||
XCTFail(error.localizedDescription) | ||
} | ||
} | ||
|
||
func test_인벤토리보다_많은과일쥬스를_만들었을때_실패을_반환하는가() { | ||
// given | ||
let fruitStore = FruitStore(initialFruitCount: 10) | ||
var juiceMaker = JuiceMaker(fruitStore: fruitStore) | ||
let input = MockJuice(items: [.banana: 15]) | ||
|
||
// when | ||
let writeResult = juiceMaker.make(with: input) | ||
|
||
// then | ||
switch writeResult { | ||
case .success(): | ||
XCTFail() | ||
case .failure(_): | ||
XCTSuccess() | ||
} | ||
} | ||
} |