-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add shortcut * feat: add training mode * feat: GetRecordGoalStrengthUsecase * feat: SubscribeTrainingModeUsecase * feat: subscribe training mode * feat: add test case * feat: add business logic * feat: CheckGoalAchievedUsecase * refactor: using usecase * feat: assign strength goal * feat: change goal view * feat: adjust ui * feat: change test case * feat: add navigation * feat: PostTraingModeUsecase * feat: manage training mode view * feat: footer
- Loading branch information
1 parent
02db66e
commit 8da18fb
Showing
33 changed files
with
681 additions
and
32 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
dg-muscle-ios/Tests/History/CheckGoalAchievedUsecaseTest.swift
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,65 @@ | ||
// | ||
// CheckGoalAchievedUsecaseTest.swift | ||
// AppTests | ||
// | ||
// Created by 신동규 on 7/13/24. | ||
// | ||
|
||
import XCTest | ||
import Domain | ||
|
||
final class CheckGoalAchievedUsecaseTest: XCTestCase { | ||
|
||
func testAchieved() { | ||
// given | ||
let usecase = CheckGoalAchievedUsecase() | ||
|
||
let goal: ExerciseSet = .init( | ||
id: UUID().uuidString, | ||
unit: .kg, | ||
reps: 13, | ||
weight: 60 | ||
) | ||
|
||
let record: ExerciseRecord = .init( | ||
id: UUID().uuidString, | ||
exerciseId: "squat", | ||
sets: [ | ||
.init(id: UUID().uuidString, unit: .kg, reps: 13, weight: 60) | ||
] | ||
) | ||
|
||
// when | ||
let result = usecase.implement(goal: goal, record: record) | ||
|
||
// then | ||
XCTAssertTrue(result) | ||
} | ||
|
||
func testNotAchieved() { | ||
// given | ||
let usecase = CheckGoalAchievedUsecase() | ||
|
||
let goal: ExerciseSet = .init( | ||
id: UUID().uuidString, | ||
unit: .kg, | ||
reps: 13, | ||
weight: 60 | ||
) | ||
|
||
let record: ExerciseRecord = .init( | ||
id: UUID().uuidString, | ||
exerciseId: "squat", | ||
sets: [ | ||
.init(id: UUID().uuidString, unit: .kg, reps: 12, weight: 60) | ||
] | ||
) | ||
|
||
// when | ||
let result = usecase.implement(goal: goal, record: record) | ||
|
||
// then | ||
XCTAssertFalse(result) | ||
} | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
dg-muscle-ios/Tests/History/CheckStrengthGoalAchievedUsecaseTest.swift
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,70 @@ | ||
// | ||
// CheckStrengthGoalAchievedUsecaseTest.swift | ||
// AppTests | ||
// | ||
// Created by 신동규 on 7/13/24. | ||
// | ||
|
||
import XCTest | ||
import Domain | ||
|
||
final class CheckStrengthGoalAchievedUsecaseTest: XCTestCase { | ||
|
||
func testFalseCase() { | ||
// given | ||
let usecase = CheckStrengthGoalAchievedUsecase() | ||
let goal: ExerciseSet = .init( | ||
id: UUID().uuidString, | ||
unit: .kg, | ||
reps: 5, | ||
weight: 65 | ||
) | ||
|
||
let record: ExerciseRecord = .init( | ||
id: UUID().uuidString, | ||
exerciseId: "squat", | ||
sets: [ | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
] | ||
) | ||
|
||
// when | ||
let result = usecase.implement(goal: goal, record: record) | ||
|
||
// then | ||
XCTAssertFalse(result) | ||
} | ||
|
||
func testTrueCase() { | ||
// given | ||
let usecase = CheckStrengthGoalAchievedUsecase() | ||
let goal: ExerciseSet = .init( | ||
id: UUID().uuidString, | ||
unit: .kg, | ||
reps: 5, | ||
weight: 60 | ||
) | ||
|
||
let record: ExerciseRecord = .init( | ||
id: UUID().uuidString, | ||
exerciseId: "squat", | ||
sets: [ | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
] | ||
) | ||
|
||
// when | ||
let result = usecase.implement(goal: goal, record: record) | ||
|
||
// then | ||
XCTAssertTrue(result) | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
dg-muscle-ios/Tests/History/GetRecordGoalStrengthUsecaseTest.swift
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,59 @@ | ||
// | ||
// GetRecordGoalStrengthUsecaseTest.swift | ||
// AppTests | ||
// | ||
// Created by 신동규 on 7/13/24. | ||
// | ||
|
||
import XCTest | ||
import Domain | ||
|
||
final class GetRecordGoalStrengthUsecaseTest: XCTestCase { | ||
|
||
func testMoreWeight() { | ||
// given | ||
let useCase = GetRecordGoalStrengthUsecase() | ||
|
||
let record: ExerciseRecord = .init( | ||
id: UUID().uuidString, | ||
exerciseId: "squat", | ||
sets: [ | ||
.init(id: UUID().uuidString, unit: .kg, reps: 15, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 15, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 5, weight: 60) | ||
] | ||
) | ||
|
||
// when | ||
let goal = useCase.implement(previousRecord: record) | ||
|
||
// then | ||
XCTAssertEqual(goal?.weight, 65) | ||
XCTAssertEqual(goal?.reps, 5) | ||
} | ||
|
||
func testSameWeigth() { | ||
// given | ||
let useCase = GetRecordGoalStrengthUsecase() | ||
|
||
let record: ExerciseRecord = .init( | ||
id: UUID().uuidString, | ||
exerciseId: "squat", | ||
sets: [ | ||
.init(id: UUID().uuidString, unit: .kg, reps: 15, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 15, weight: 60), | ||
.init(id: UUID().uuidString, unit: .kg, reps: 15, weight: 60) | ||
] | ||
) | ||
|
||
// when | ||
let goal = useCase.implement(previousRecord: record) | ||
|
||
// then | ||
XCTAssertEqual(goal?.weight, 60) | ||
XCTAssertEqual(goal?.reps, 5) | ||
} | ||
|
||
} |
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
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
32 changes: 32 additions & 0 deletions
32
dg-muscle-ios/sources/DataLayer/User/Model/TrainingMode.swift
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,32 @@ | ||
// | ||
// TrainingMode.swift | ||
// DataLayer | ||
// | ||
// Created by 신동규 on 7/13/24. | ||
// | ||
|
||
import Foundation | ||
import Domain | ||
|
||
public enum TrainingMode: Codable { | ||
case mass | ||
case strength | ||
|
||
init(domain: Domain.TrainingMode) { | ||
switch domain { | ||
case .mass: | ||
self = .mass | ||
case .strength: | ||
self = .strength | ||
} | ||
} | ||
|
||
var domain: Domain.TrainingMode { | ||
switch self { | ||
case .mass: | ||
return .mass | ||
case .strength: | ||
return .strength | ||
} | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
dg-muscle-ios/sources/Domain/History/Usecase/CheckGoalAchievedUsecase.swift
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,18 @@ | ||
// | ||
// CheckGoalAchievedUsecase.swift | ||
// Domain | ||
// | ||
// Created by 신동규 on 7/13/24. | ||
// | ||
|
||
import Foundation | ||
|
||
public final class CheckGoalAchievedUsecase { | ||
public init() { } | ||
|
||
public func implement(goal: ExerciseSet, record: ExerciseRecord) -> Bool { | ||
return !record.sets.filter({ set in | ||
goal.weight <= set.weight && goal.reps <= set.reps | ||
}).isEmpty | ||
} | ||
} |
Oops, something went wrong.