Skip to content

Commit

Permalink
- Count circuit not as 1 exercise but as the count of managed exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
piscoTech committed Oct 13, 2018
1 parent 0758b33 commit 93ef7c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gym Tracker Core/GTWorkout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final public class GTWorkout: GTDataObject, NamedExercizeCollection {
@NSManaged public var archived: Bool

public override var description: String {
let n = parts.filter { $0 is GTExercize }.count
let n = parts.reduce(0) { $0 + (($1 as? GTCircuit)?.exercizes.count ?? ($1 is GTSetsExercize ? 1 : 0)) }
return "\(n) " + GTLocalizedString("EXERCIZE" + (n > 1 ? "S" : ""), comment: "exercize(s)").lowercased()
}

Expand Down
22 changes: 22 additions & 0 deletions Gym Tracker Tests/GTWorkoutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ class GTWorkoutTests: XCTestCase {
super.tearDown()
}

func testDescription() {
let workout = dataManager.newWorkout()

let e1 = newValidExercize()
workout.add(parts: e1)
XCTAssertTrue(workout.description.hasPrefix("1"), "Unexpected description '\(workout.description)'")
let e2 = newValidExercize()
workout.add(parts: e2)
XCTAssertTrue(workout.description.hasPrefix("2"), "Unexpected description '\(workout.description)'")

let ch = dataManager.newChoice()
workout.add(parts: ch)
ch.add(parts: e1, e2)
XCTAssertTrue(workout.description.hasPrefix("1"), "Unexpected description '\(workout.description)'")

let e3 = newValidExercize()
let c = dataManager.newCircuit()
workout.add(parts: c)
c.add(parts: ch, e3)
XCTAssertTrue(workout.description.hasPrefix("2"), "Unexpected description '\(workout.description)'")
}

func testIsValid() {
XCTAssertFalse(workout.isSubtreeValid)
XCTAssertFalse(workout.isValid)
Expand Down

0 comments on commit 93ef7c3

Please sign in to comment.