-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d0d93f
commit 4cf6ed1
Showing
8 changed files
with
114 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
repository/OpenPonk-Core/OPExamplePersistenceTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
Class { | ||
#name : 'OPExamplePersistenceTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'file', | ||
'sourceWorkbench', | ||
'targetWorkbench' | ||
], | ||
#category : 'OpenPonk-Core-Tests', | ||
#package : 'OpenPonk-Core', | ||
#tag : 'Tests' | ||
} | ||
|
||
{ #category : 'testing' } | ||
OPExamplePersistenceTest class >> isAbstract [ | ||
|
||
^ self = OPExamplePersistenceTest | ||
] | ||
|
||
{ #category : 'hooks' } | ||
OPExamplePersistenceTest >> createExampleModel [ | ||
|
||
^ self subclassResponsibility | ||
] | ||
|
||
{ #category : 'running' } | ||
OPExamplePersistenceTest >> setUp [ | ||
|
||
super setUp. | ||
file := FileSystem memory root / 'example-persistence-test.opp'. | ||
file ensureDelete | ||
] | ||
|
||
{ #category : 'running' } | ||
OPExamplePersistenceTest >> tearDown [ | ||
|
||
sourceWorkbench ifNotNil: [ :workbench | | ||
workbench application closeAllWindows. | ||
sourceWorkbench := nil ]. | ||
targetWorkbench ifNotNil: [ :workbench | | ||
workbench application closeAllWindows. | ||
targetWorkbench := nil ]. | ||
file ifNotNil: [ | ||
file ensureDelete. | ||
file := nil ]. | ||
Smalltalk garbageCollect. | ||
super tearDown | ||
] | ||
|
||
{ #category : 'tests' } | ||
OPExamplePersistenceTest >> testSaveAndLoad [ | ||
|
||
| sourceModel sourceProject sourceEditor sourceCanvas sourceProjectController sourceShapes targetProject targetEditor targetCanvas targetShapes | | ||
sourceModel := self createExampleModel. | ||
sourceProject := OPProject new | ||
name: 'TestProject'; | ||
addModel: sourceModel; | ||
yourself. | ||
sourceWorkbench := sourceProject open. | ||
sourceWorkbench showAllElementsInAllDiagrams. | ||
sourceEditor := sourceWorkbench focusedEditor. | ||
sourceCanvas := sourceEditor canvasPresenter canvas. | ||
sourceShapes := sourceCanvas shapes | ||
collect: [ :each | each class ] | ||
as: Bag. | ||
self denyCollection: sourceShapes equals: Bag empty. | ||
sourceProjectController := sourceWorkbench projectController. | ||
sourceProjectController saveProjectTo: file. | ||
|
||
targetProject := OPProjectController fromFile: file. | ||
targetWorkbench := targetProject open. | ||
targetWorkbench showAllElementsInAllDiagrams. | ||
targetEditor := targetWorkbench focusedEditor. | ||
targetCanvas := targetEditor canvasPresenter canvas. | ||
targetShapes := targetCanvas shapes | ||
collect: [ :each | each class ] | ||
as: Bag. | ||
self assertCollection: targetShapes equals: sourceShapes | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters