[Pharo] Personal fitness tracker web app.
1
"
2
A MFTSetPrescriptionTest is a test class for testing the behavior of MFTSetPrescription
3
"
4
Class {
5
#name : 'MFTSetPrescriptionTest',
6
#superclass : 'TestCase',
7
#category : 'MyFitnessTracker-Core-Tests-Prescription',
8
#package : 'MyFitnessTracker-Core-Tests',
9
#tag : 'Prescription'
10
}
11
12
{ #category : 'tests' }
13
MFTSetPrescriptionTest >> testCanonicalNameCombinesRepSchemeAndExerciseNames [
14
15
| exercise repScheme prescription |
16
exercise := MFTRepScheme from: 1 to: 1.
17
repScheme := MFTRepScheme from: 6 to: 10.
18
prescription := MFTSetPrescription new.
19
prescription
20
instVarNamed: 'exercise' put: exercise;
21
repScheme: repScheme.
22
23
self assert: prescription canonicalName equals: '6–10 reps 1–1'
24
]
25
26
{ #category : 'tests' }
27
MFTSetPrescriptionTest >> testEqualPrescriptionsHaveSameHash [
28
29
| exercise repScheme first second |
30
exercise := MFTRepScheme from: 1 to: 1.
31
repScheme := MFTRepScheme from: 6 to: 10.
32
first := MFTSetPrescription new.
33
second := MFTSetPrescription new.
34
first
35
instVarNamed: 'exercise' put: exercise;
36
repScheme: repScheme.
37
second
38
instVarNamed: 'exercise' put: exercise;
39
repScheme: repScheme.
40
41
self assert: first hash equals: second hash
42
]
43
44
{ #category : 'tests' }
45
MFTSetPrescriptionTest >> testExerciseInitiallyNil [
46
47
| prescription |
48
prescription := MFTSetPrescription new.
49
50
self assert: prescription exercise isNil
51
]
52
53
{ #category : 'tests' }
54
MFTSetPrescriptionTest >> testExerciseRepSchemeConstructorSetsExerciseAndRepScheme [
55
56
| exercise repScheme prescription |
57
exercise := MFTRepScheme from: 1 to: 1.
58
repScheme := MFTRepScheme from: 6 to: 10.
59
60
prescription := MFTSetPrescription
61
exercise: exercise
62
repScheme: repScheme.
63
64
self assert: prescription exercise identicalTo: exercise.
65
self assert: prescription repScheme identicalTo: repScheme
66
]
67
68
{ #category : 'tests' }
69
MFTSetPrescriptionTest >> testPrescriptionIsNotEqualToDifferentClass [
70
71
| prescription |
72
prescription := MFTSetPrescription new.
73
prescription
74
instVarNamed: 'exercise' put: (MFTRepScheme from: 1 to: 1);
75
repScheme: (MFTRepScheme from: 6 to: 10).
76
self deny: prescription equals: Object new
77
]
78
79
{ #category : 'tests' }
80
MFTSetPrescriptionTest >> testPrescriptionsWithDifferentExerciseAreNotEqual [
81
82
| repScheme first second |
83
repScheme := MFTRepScheme from: 6 to: 10.
84
first := MFTSetPrescription new.
85
second := MFTSetPrescription new.
86
first
87
instVarNamed: 'exercise' put: (MFTRepScheme from: 1 to: 1);
88
repScheme: repScheme.
89
second
90
instVarNamed: 'exercise' put: (MFTRepScheme from: 2 to: 2);
91
repScheme: repScheme.
92
self deny: first equals: second
93
]
94
95
{ #category : 'tests' }
96
MFTSetPrescriptionTest >> testPrescriptionsWithDifferentRepSchemeAreNotEqual [
97
98
| exercise first second |
99
exercise := MFTRepScheme from: 1 to: 1.
100
first := MFTSetPrescription new.
101
second := MFTSetPrescription new.
102
first
103
instVarNamed: 'exercise' put: exercise;
104
repScheme: (MFTRepScheme from: 6 to: 10).
105
second
106
instVarNamed: 'exercise' put: exercise;
107
repScheme: (MFTRepScheme from: 8 to: 12).
108
self deny: first equals: second
109
]
110
111
{ #category : 'tests' }
112
MFTSetPrescriptionTest >> testPrescriptionsWithSameExerciseAndRepSchemeAreEqual [
113
114
| exercise repScheme first second |
115
exercise := MFTRepScheme from: 1 to: 1.
116
repScheme := MFTRepScheme from: 6 to: 10.
117
first := MFTSetPrescription new.
118
second := MFTSetPrescription new.
119
first
120
instVarNamed: 'exercise' put: exercise;
121
repScheme: repScheme.
122
second
123
instVarNamed: 'exercise' put: exercise;
124
repScheme: repScheme.
125
126
self assert: first equals: second
127
]
128
129
{ #category : 'tests' }
130
MFTSetPrescriptionTest >> testRepSchemeAccessor [
131
132
| prescription repScheme |
133
prescription := MFTSetPrescription new.
134
repScheme := MFTRepScheme from: 6 to: 10.
135
136
prescription repScheme: repScheme.
137
138
self assert: prescription repScheme identicalTo: repScheme
139
]
140