-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
7 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
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
81 changes: 81 additions & 0 deletions
81
src/test/java/de/avalax/fitbuddy/presentation/helper/ExerciseViewHelperTest.java
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,81 @@ | ||
package de.avalax.fitbuddy.presentation.helper; | ||
|
||
import de.avalax.fitbuddy.domain.model.exercise.BasicExercise; | ||
import de.avalax.fitbuddy.domain.model.exercise.Exercise; | ||
import de.avalax.fitbuddy.domain.model.set.BasicSet; | ||
import de.avalax.fitbuddy.domain.model.set.Set; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.Locale; | ||
|
||
import static org.hamcrest.core.IsEqual.equalTo; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class ExerciseViewHelperTest { | ||
private ExerciseViewHelper exerciseViewHelper; | ||
|
||
private BasicExercise createExerciseWithWeight(double weight) { | ||
BasicExercise exercise = new BasicExercise(); | ||
BasicSet set = new BasicSet(); | ||
set.setWeight(weight); | ||
exercise.addSet(set); | ||
return exercise; | ||
} | ||
|
||
private BasicExercise createExerciseWithName(String name) { | ||
BasicExercise exercise = new BasicExercise(); | ||
exercise.setName(name); | ||
return exercise; | ||
} | ||
|
||
private Exercise createExerciseWithMaxReps(int maxReps) { | ||
Exercise exercise = new BasicExercise(); | ||
Set set = new BasicSet(); | ||
set.setMaxReps(maxReps); | ||
exercise.addSet(set); | ||
return exercise; | ||
} | ||
|
||
private BasicExercise createExerciseWithOneSet() { | ||
BasicExercise exercise = new BasicExercise(); | ||
exercise.addSet(new BasicSet()); | ||
return exercise; | ||
} | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
exerciseViewHelper = new ExerciseViewHelper(Locale.ENGLISH); | ||
} | ||
|
||
@Test | ||
public void testWeightOfExercise() throws Exception { | ||
assertThat(exerciseViewHelper.weightOfExercise(null), equalTo("-")); | ||
assertThat(exerciseViewHelper.weightOfExercise(new BasicExercise()), equalTo("-")); | ||
assertThat(exerciseViewHelper.weightOfExercise(createExerciseWithWeight(0.0)), equalTo("-")); | ||
assertThat(exerciseViewHelper.weightOfExercise(createExerciseWithWeight(10.0)), equalTo("10")); | ||
assertThat(exerciseViewHelper.weightOfExercise(createExerciseWithWeight(0.725)), equalTo("0.725")); | ||
assertThat(exerciseViewHelper.weightOfExercise(createExerciseWithWeight(-0.725)), equalTo("-0.725")); | ||
} | ||
|
||
@Test | ||
public void testNameOfExercise() throws Exception { | ||
assertThat(exerciseViewHelper.nameOfExercise(null), equalTo("unnamed exercise")); | ||
assertThat(exerciseViewHelper.nameOfExercise(new BasicExercise()), equalTo("unnamed exercise")); | ||
assertThat(exerciseViewHelper.nameOfExercise(createExerciseWithName("my new exercise")), equalTo("my new exercise")); | ||
} | ||
|
||
@Test | ||
public void testMaxRepsOfExercise() throws Exception { | ||
assertThat(exerciseViewHelper.maxRepsOfExercise(null), equalTo(0)); | ||
assertThat(exerciseViewHelper.maxRepsOfExercise(new BasicExercise()), equalTo(0)); | ||
assertThat(exerciseViewHelper.maxRepsOfExercise(createExerciseWithMaxReps(12)), equalTo(12)); | ||
} | ||
|
||
@Test | ||
public void testSetCountOfExercise() throws Exception { | ||
assertThat(exerciseViewHelper.setCountOfExercise(null), equalTo(0)); | ||
assertThat(exerciseViewHelper.setCountOfExercise(new BasicExercise()), equalTo(0)); | ||
assertThat(exerciseViewHelper.setCountOfExercise(createExerciseWithOneSet()), equalTo(1)); | ||
} | ||
} |