Skip to content

Commit

Permalink
Add TU
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Aug 1, 2024
1 parent bd68944 commit 5bbc22a
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 0 deletions.
116 changes: 116 additions & 0 deletions src/Pyramid-Tests/PyramidEditorBuilderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,119 @@ PyramidEditorBuilderTest >> testBuild2 [
self assert: plugin1 isInstalled.
self deny: plugin2 isInstalled
]

{ #category : #tests }
PyramidEditorBuilderTest >> testCommandExecutor [

| builder target1 target2 editor |
target1 := PyramidMainCommandExecutor new.
target2 := PyramidMainCommandExecutor new.

"Default value is not nil"
builder := PyramidEditorBuilder new.
self assert: builder commandExecutor isNotNil.

"editor is correctly set"
builder := PyramidEditorBuilder new.
builder commandExecutor: target1.
self assert: builder commandExecutor equals: target1.
editor := builder build.
self assert: editor commandExecutor equals: target1.

"cannot set twice"
builder := PyramidEditorBuilder new.
builder commandExecutor: target1.
self assert: builder commandExecutor equals: target1.
[
builder commandExecutor: target2.
self fail ]
on: PyramidBuilderAlreadyConfiguredError
do: [ self assert: true ]
]

{ #category : #tests }
PyramidEditorBuilderTest >> testEditor [

| builder target1 target2 editor |
target1 := PyramidEditor new.
target2 := PyramidEditor new.

"Default value is not nil"
builder := PyramidEditorBuilder new.
self assert: builder editor isNotNil.

"editor is correctly set"
builder := PyramidEditorBuilder new.
builder editor: target1.
self assert: builder editor equals: target1.
editor := builder build.
self assert: editor equals: target1.

"cannot set twice"
builder := PyramidEditorBuilder new.
builder editor: target1.
self assert: builder editor equals: target1.
[
builder editor: target2.
self fail ]
on: PyramidBuilderAlreadyConfiguredError
do: [ self assert: true ]
]

{ #category : #tests }
PyramidEditorBuilderTest >> testProjectModel [

| builder target1 target2 editor |
target1 := PyramidProjectModel new.
target2 := PyramidProjectModel new.

"Default value is not nil"
builder := PyramidEditorBuilder new.
self assert: builder projectModel isNotNil.

"editor is correctly set"
builder := PyramidEditorBuilder new.
builder projectModel: target1.
self assert: builder projectModel equals: target1.
editor := builder build.
self assert: editor projectModel equals: target1.

"cannot set twice"
builder := PyramidEditorBuilder new.
builder projectModel: target1.
self assert: builder projectModel equals: target1.
[
builder projectModel: target2.
self fail ]
on: PyramidBuilderAlreadyConfiguredError
do: [ self assert: true ]
]

{ #category : #tests }
PyramidEditorBuilderTest >> testWindow [

| builder target1 target2 editor |
target1 := PyramidSimpleWindow new.
target2 := PyramidSimpleWindow new.

"Default value is not nil"
builder := PyramidEditorBuilder new.
self assert: builder window isNotNil.

"editor is correctly set"
builder := PyramidEditorBuilder new.
builder window: target1.
self assert: builder window equals: target1.
editor := builder build.
self assert: editor window equals: target1.

"cannot set twice"
builder := PyramidEditorBuilder new.
builder window: target1.
self assert: builder window equals: target1.
[
builder window: target2.
self fail ]
on: PyramidBuilderAlreadyConfiguredError
do: [ self assert: true ]
]
5 changes: 5 additions & 0 deletions src/Pyramid-Tests/PyramidFakePlugin1.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #PyramidFakePlugin1,
#superclass : #PyramidFakePlugin,
#category : #'Pyramid-Tests-cases-core'
}
5 changes: 5 additions & 0 deletions src/Pyramid-Tests/PyramidFakePlugin2.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #PyramidFakePlugin2,
#superclass : #PyramidFakePlugin,
#category : #'Pyramid-Tests-cases-core'
}
5 changes: 5 additions & 0 deletions src/Pyramid-Tests/PyramidFakePlugin3.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #PyramidFakePlugin3,
#superclass : #PyramidFakePlugin,
#category : #'Pyramid-Tests-cases-core'
}
85 changes: 85 additions & 0 deletions src/Pyramid-Tests/TPyramidFindPluginTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
Class {
#name : #TPyramidFindPluginTest,
#superclass : #TestCase,
#traits : 'TPyramidFindPlugin',
#classTraits : 'TPyramidFindPlugin classTrait',
#instVars : [
'object1',
'object2',
'object3'
],
#category : #'Pyramid-Tests-cases-core'
}

{ #category : #accessing }
TPyramidFindPluginTest >> object1 [

^ object1
]

{ #category : #accessing }
TPyramidFindPluginTest >> object2 [

^ object2
]

{ #category : #accessing }
TPyramidFindPluginTest >> object3 [

^ object3
]

{ #category : #accessing }
TPyramidFindPluginTest >> plugins [
"Return a collection of TPyramidPlugin instances."

^ {
self object1.
self object2.
self object3.
self object3 }
]

{ #category : #accessing }
TPyramidFindPluginTest >> setUp [

super setUp.

object1 := PyramidFakePlugin1 new.
object2 := PyramidFakePlugin2 new.
object3 := PyramidFakePlugin3 new
]

{ #category : #tests }
TPyramidFindPluginTest >> testFindPlugin [

self
assert: (self findPlugin: PyramidFakePlugin1)
equals: self object1.
self
assert: (self findPlugin: #PyramidFakePlugin2)
equals: self object2.
[
self findPlugin: #PyramidFakePlugin3.
self fail ]
on: PyramidMultiplePluginsFoundError
do: [ :err |
self assert: err plugins size equals: 2.
self assert: err plugins first equals: self object3.
self assert: err plugins last equals: self object3 ].
[
self findPlugin: PyramidFakePlugin3.
self fail ]
on: PyramidMultiplePluginsFoundError
do: [ :err |
self assert: err plugins size equals: 2.
self assert: err plugins first equals: self object3.
self assert: err plugins last equals: self object3 ].
[
self findPlugin: #PyramidFakePlugin4.
self fail ]
on: PyramidNoPluginFoundError
do: [ :err |
self assert: err query equals: #PyramidFakePlugin4.
]
]
1 change: 1 addition & 0 deletions src/Pyramid/PyramidEditorBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ PyramidEditorBuilder >> editor: anObject [
{ #category : #accessing }
PyramidEditorBuilder >> plugins [

plugins ifNil: [ plugins := { } ].
^ plugins
]

Expand Down

0 comments on commit 5bbc22a

Please sign in to comment.