SimpleTestResourceTestCase.st
author Stefan Vogel <sv@exept.de>
Fri, 26 Sep 2003 18:01:01 +0200
changeset 108 7509607479f5
child 222 8e6f482297fa
permissions -rw-r--r--
initial checkin

"{ Package: 'stx:goodies/sunit' }"

TestCase subclass:#SimpleTestResourceTestCase
	instanceVariableNames:'resource'
	classVariableNames:''
	poolDictionaries:''
	category:'SUnit-Tests'
!

TestResource subclass:#SimpleTestResource
	instanceVariableNames:'runningState hasRun hasSetup hasRanOnce'
	classVariableNames:''
	poolDictionaries:''
	privateIn:SimpleTestResourceTestCase
!


!SimpleTestResourceTestCase class methodsFor:'Not categorized'!

resources
	^Set new add: SimpleTestResource; yourself
			
! !

!SimpleTestResourceTestCase methodsFor:'Not categorized'!

dummy
	self assert: true
			
!

error
	'foo' odd
			
!

fail
	self assert: false
			
!

setRun
	resource setRun
			
!

setUp
	resource := SimpleTestResource current
			
!

testRan
	| case |

	case := self class selector: #setRun.
	case run.
	self assert: resource hasSetup.
	self assert: resource hasRun
			
!

testResourceInitRelease
	| result suite error failure |
	suite := TestSuite new.
	suite addTest: (error := self class selector: #error).
	suite addTest: (failure := self class selector: #fail).
	suite addTest: (self class selector: #dummy).
	result := suite run.
	self assert: resource hasSetup
			
!

testResourcesCollection
	| collection |
	collection := self resources.
	self assert: collection size = 1
			
! !

!SimpleTestResourceTestCase::SimpleTestResource methodsFor:'accessing'!

runningState

	^runningState
			
!

runningState: aSymbol

	runningState := aSymbol
			
! !

!SimpleTestResourceTestCase::SimpleTestResource methodsFor:'running'!

setRun
	hasRun := true
			
!

setUp
	
	self runningState: self startedStateSymbol.
	hasSetup := true
			
!

startedStateSymbol

	^#started
			
!

stoppedStateSymbol

	^#stopped
			
!

tearDown

	self runningState: self stoppedStateSymbol
			
! !

!SimpleTestResourceTestCase::SimpleTestResource methodsFor:'testing'!

hasRun
	^hasRun
			
!

hasSetup
	^hasSetup
			
!

isAvailable
	
	^self runningState == self startedStateSymbol
			
! !

!SimpleTestResourceTestCase class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/sunit/SimpleTestResourceTestCase.st,v 1.1 2003-09-26 16:01:01 stefan Exp $'
! !