test/MCFileInTest.st
author Claus Gittinger <cg@exept.de>
Wed, 22 Nov 2006 14:02:13 +0100
changeset 19 17ff4ce04f1f
child 153 1bab1f6eed93
permissions -rw-r--r--
initial checkin

"{ Package: 'stx:goodies/monticello/test' }"

MCTestCase subclass:#MCFileInTest
	instanceVariableNames:'stream expected diff'
	classVariableNames:''
	poolDictionaries:''
	category:'Monticello-Tests'
!


!MCFileInTest methodsFor:'asserting'!

assertNoChange
	| actual |
	actual _ MCSnapshotResource takeSnapshot.
	diff _ actual patchRelativeToBase: expected.
	self assert: diff isEmpty
! !

!MCFileInTest methodsFor:'running'!

setUp
	expected _ self mockSnapshot.
	stream _ RWBinaryOrTextStream on: String new.
!

tearDown
	(diff isNil or: [diff isEmpty not])
		 ifTrue: [expected updatePackage: self mockPackage]
! !

!MCFileInTest methodsFor:'testing'!

alterInitialState
	self mockClassA touchCVar
!

assertFileOutFrom: writerClass canBeFiledInWith: aBlock
	(writerClass on: stream) writeSnapshot: self mockSnapshot.
	self alterInitialState.
	self assertSuccessfulLoadWith: aBlock.
	self mockPackage unload.
	self assertSuccessfulLoadWith: aBlock.
!

assertInitializersCalled
	| cvar |
	cvar _ self mockClassA cVar.
	self assert: cvar = #initialized
!

assertSuccessfulLoadWith: aBlock
	stream reset.
	aBlock value.
	self assertNoChange.
	self assertInitializersCalled.
!

testStWriter
	self
		assertFileOutFrom: MCStWriter
		canBeFiledInWith: [stream fileIn].
! !

!MCFileInTest class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/goodies/monticello/test/MCFileInTest.st,v 1.1 2006-11-22 13:02:13 cg Exp $'
! !