Initialization method tested
This commit is contained in:
@@ -16,6 +16,11 @@ Class {
|
||||
#category : #MyCounter
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
Counter class >> startingAt: anInteger [
|
||||
^ self new count: anInteger
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Counter >> count [
|
||||
|
||||
@@ -28,14 +33,20 @@ Counter >> count: anInteger [
|
||||
count := anInteger
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : #operation }
|
||||
Counter >> decrement [
|
||||
|
||||
count := count - 1
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : #operation }
|
||||
Counter >> increment [
|
||||
|
||||
count := count + 1
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
Counter >> initialize [
|
||||
super initialize.
|
||||
count := 0
|
||||
]
|
||||
|
@@ -12,6 +12,11 @@ CounterTest >> testCountIsSetAndRead [
|
||||
self assert: c count equals: 7
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
CounterTest >> testCounterWellInitialized [
|
||||
self assert: (Counter new increment; increment; count) equals: 2
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
CounterTest >> testDecrement [
|
||||
| c |
|
||||
@@ -29,3 +34,22 @@ CounterTest >> testIncrement [
|
||||
c increment; increment.
|
||||
self assert: c count equals: 4
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
CounterTest >> testInizialize [
|
||||
self assert: Counter new count equals: 0
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
CounterTest >> testStartingAt5 [
|
||||
| c |
|
||||
c := Counter startingAt: 5.
|
||||
self assert: c count equals: 5
|
||||
]
|
||||
|
||||
{ #category : #tests }
|
||||
CounterTest >> testStartingAt5Increment [
|
||||
| c |
|
||||
c := Counter startingAt: 5.
|
||||
self assert: (c increment; count) equals: 6
|
||||
]
|
||||
|
Reference in New Issue
Block a user