-
Notifications
You must be signed in to change notification settings - Fork 12
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
WIP: Exercise1: Unit Test for Keangnam Beer #12
base: master
Are you sure you want to change the base?
Conversation
static func createDayWith(string: String) -> Date { | ||
let formatter = DateFormatter() | ||
formatter.dateFormat = "yyyy/MM/dd HH:mm:ss" | ||
formatter.timeZone = TimeZone(secondsFromGMT: 7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
secondsFromGMT
, tính theo 7 giây thì có vẻ sai nhỉ, phải là 7 giờ chứ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Đang tính theo giờ đó anh, Exercise2 cũng viết func này. Em chỉ copy ra extension để dùng thôi.
@@ -20,6 +20,13 @@ extension Date { | |||
return DayInWeek(rawValue: calendar.dateComponents([.weekday], from: self).weekday ?? 0) ?? .none | |||
} | |||
|
|||
static func createDayWith(string: String) -> Date { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static func createDayWith(string: String) -> Date { | |
static func createDayWith(string: String) -> Date? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hàm này có trả về default là Date() rồi ạ
} | ||
|
||
func test_notUseVoucher_inPromotionTime() { | ||
let date = Date.createDayWith(string: "2022/05/18 10:10:00") // 17:10:00 // +7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
có thể dùng Date(hour: 10)
func test_calculateBeerPrice() { | ||
loadTrigger.onNext(()) | ||
|
||
XCTAssert(self.useCase.calculateBeerPriceCalled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thêm dòng kiểm tra output.price
vd: XCTAssertEqual(output.price, (490.0).japanCurrency)
loadTrigger.onNext(()) | ||
|
||
XCTAssert(self.useCase.calculateBeerPriceCalled) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thiếu test:
- test_voucherTrigger_calculateBeerPrice
- test_promotionTimeTrigger_calculateBeerPrice
LGTM! |
Exercise1: Unit Test for Keangnam Beer
LGTM |
No description provided.