[Pharo] Personal fitness tracker web app.
1
"
2
A MFTSetGroupLogTest is a test class for testing the behavior of MFTSetGroupLog
3
"
4
Class {
5
#name : 'MFTSetGroupLogTest',
6
#superclass : 'TestCase',
7
#category : 'MyFitnessTracker-Core-Tests-Logging',
8
#package : 'MyFitnessTracker-Core-Tests',
9
#tag : 'Logging'
10
}
11
12
{ #category : 'tests' }
13
MFTSetGroupLogTest >> testAddSetAppendsSetLog [
14
15
| groupLog firstSet secondSet |
16
groupLog := MFTSetGroupLog new.
17
firstSet := MFTSetLog new.
18
secondSet := MFTSetLog new.
19
20
groupLog addSet: firstSet.
21
groupLog addSet: secondSet.
22
23
self assert: groupLog sets asArray equals: {
24
firstSet.
25
secondSet }
26
]
27
28
{ #category : 'tests' }
29
MFTSetGroupLogTest >> testEmptyGroupLogIsCompletelyLogged [
30
31
| groupLog |
32
groupLog := MFTSetGroupLog new.
33
34
self assert: groupLog isCompletelyLogged
35
]
36
37
{ #category : 'tests' }
38
MFTSetGroupLogTest >> testGroupLogIsCompletelyLoggedWhenAllSetsAreLogged [
39
40
| groupLog |
41
groupLog := MFTSetGroupLog new.
42
groupLog sets: {
43
(MFTSetLog reps: 6 load: 100).
44
(MFTSetLog reps: 5 load: 110) }.
45
46
self assert: groupLog isCompletelyLogged
47
]
48
49
{ #category : 'tests' }
50
MFTSetGroupLogTest >> testGroupLogIsNotCompletelyLoggedWhenAnySetIsUnlogged [
51
52
| groupLog |
53
groupLog := MFTSetGroupLog new.
54
groupLog sets: {
55
(MFTSetLog reps: 6 load: 100).
56
MFTSetLog new }.
57
58
self deny: groupLog isCompletelyLogged
59
]
60
61
{ #category : 'tests' }
62
MFTSetGroupLogTest >> testNewGroupLogStartsWithEmptySetsAndNotes [
63
64
| groupLog |
65
groupLog := MFTSetGroupLog new.
66
67
self assert: groupLog sets isEmpty.
68
self assert: groupLog notes equals: String new
69
]
70
71
{ #category : 'tests' }
72
MFTSetGroupLogTest >> testNotesCanBeRecorded [
73
74
| groupLog |
75
groupLog := MFTSetGroupLog new.
76
groupLog notes: 'Felt strong, but recovery still incomplete.'.
77
78
self
79
assert: groupLog notes
80
equals: 'Felt strong, but recovery still incomplete.'
81
]
82
83
{ #category : 'tests' }
84
MFTSetGroupLogTest >> testPrescriptionCanBeRecorded [
85
86
| groupLog prescription |
87
groupLog := MFTSetGroupLog new.
88
prescription := Object new.
89
groupLog prescription: prescription.
90
91
self assert: groupLog prescription identicalTo: prescription
92
]
93
94
{ #category : 'tests' }
95
MFTSetGroupLogTest >> testSetLogForPrescriptionRaisesErrorWhenPrescriptionIsUnknown [
96
97
| groupLog knownPrescription unknownPrescription knownLog |
98
groupLog := MFTSetGroupLog new.
99
knownPrescription := Object new.
100
unknownPrescription := Object new.
101
knownLog := MFTSetLog forPrescription: knownPrescription.
102
groupLog addSet: knownLog.
103
104
self
105
should: [ groupLog setLogForPrescription: unknownPrescription ]
106
raise: Error
107
]
108
109
{ #category : 'tests' }
110
MFTSetGroupLogTest >> testSetLogForPrescriptionReturnsMatchingSetLogByIdentity [
111
112
| groupLog firstPrescription secondPrescription firstLog secondLog |
113
groupLog := MFTSetGroupLog new.
114
firstPrescription := Object new.
115
secondPrescription := Object new.
116
firstLog := MFTSetLog forPrescription: firstPrescription.
117
secondLog := MFTSetLog forPrescription: secondPrescription.
118
groupLog sets: {
119
firstLog.
120
secondLog }.
121
122
self
123
assert: (groupLog setLogForPrescription: secondPrescription)
124
identicalTo: secondLog
125
]
126