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

WIP: Exercise1: Unit Test for Keangnam Beer #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

baotq-3040
Copy link

No description provided.

static func createDayWith(string: String) -> Date {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy/MM/dd HH:mm:ss"
formatter.timeZone = TimeZone(secondsFromGMT: 7)
Copy link
Owner

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ứ

Copy link
Author

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 {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
static func createDayWith(string: String) -> Date {
static func createDayWith(string: String) -> Date? {

Copy link
Author

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
Copy link
Owner

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)
Copy link
Owner

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)
}
Copy link
Owner

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

@tuanta-0175
Copy link
Owner

LGTM!

Exercise1: Unit Test for Keangnam Beer
@namnt-1082
Copy link

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants