View raw

1 " 2 A MFTRoutineTest is a test class for testing the behavior of MFTRoutine 3 " 4 Class { 5 #name : 'MFTRoutineTest', 6 #superclass : 'TestCase', 7 #category : 'MyFitnessTracker-Core-Tests-Prescription', 8 #package : 'MyFitnessTracker-Core-Tests', 9 #tag : 'Prescription' 10 } 11 12 { #category : 'tests' } 13 MFTRoutineTest >> testCanonicalNameAnswersTitle [ 14 15 | routine | 16 routine := MFTRoutine new. 17 18 routine title: 'Heavy Duty I'. 19 20 self assert: routine canonicalName equals: 'Heavy Duty I' 21 ] 22 23 { #category : 'tests' } 24 MFTRoutineTest >> testInitializeCreatesEmptyWorkoutCollection [ 25 26 | routine | 27 routine := MFTRoutine new. 28 29 self assert: routine workouts isEmpty 30 ] 31 32 { #category : 'tests' } 33 MFTRoutineTest >> testTitleAccessor [ 34 35 | routine | 36 routine := MFTRoutine new. 37 routine title: 'Heavy Duty I'. 38 39 self assert: routine title equals: 'Heavy Duty I' 40 ] 41 42 { #category : 'tests' } 43 MFTRoutineTest >> testWorkoutAfterAnswersNilWhenRoutineHasNoWorkouts [ 44 45 | routine | 46 routine := MFTRoutine new. 47 48 self assert: (routine workoutAfter: #unknown) isNil 49 ] 50 51 { #category : 'tests' } 52 MFTRoutineTest >> testWorkoutAfterKnownWorkoutAnswersFollowingWorkout [ 53 54 | routine | 55 routine := MFTRoutine new. 56 routine workouts: #( day1 day2 day3 ). 57 58 self assert: (routine workoutAfter: #day1) equals: #day2. 59 self assert: (routine workoutAfter: #day2) equals: #day3 60 ] 61 62 { #category : 'tests' } 63 MFTRoutineTest >> testWorkoutAfterLastWorkoutWrapsToFirstWorkout [ 64 65 | routine | 66 routine := MFTRoutine new. 67 routine workouts: #( day1 day2 day3 ). 68 69 self assert: (routine workoutAfter: #day3) equals: #day1 70 ] 71 72 { #category : 'tests' } 73 MFTRoutineTest >> testWorkoutAfterUnknownWorkoutAnswersFirstWorkout [ 74 75 | routine | 76 routine := MFTRoutine new. 77 routine workouts: #( day1 day2 day3 ). 78 79 self assert: (routine workoutAfter: #unknown) equals: #day1 80 ] 81 82 { #category : 'tests' } 83 MFTRoutineTest >> testWorkoutsSetterStoresAnArray [ 84 85 | routine workouts | 86 routine := MFTRoutine new. 87 workouts := OrderedCollection with: #day1 with: #day2. 88 89 routine workouts: workouts. 90 91 self assert: routine workouts class equals: OrderedCollection. 92 self assert: routine workouts equals: workouts 93 ] 94