|
1 "{ Package: 'jn:refactoring_custom' }" |
|
2 |
|
3 TestCase subclass:#CustomSubContextTests |
|
4 instanceVariableNames:'model context' |
|
5 classVariableNames:'' |
|
6 poolDictionaries:'' |
|
7 category:'Interface-Refactoring-Custom-Tests' |
|
8 ! |
|
9 |
|
10 !CustomSubContextTests methodsFor:'initialization & release'! |
|
11 |
|
12 setUp |
|
13 super setUp. |
|
14 |
|
15 model := CustomNamespace new. |
|
16 context := CustomSubContext new |
|
17 model: model; |
|
18 yourself |
|
19 |
|
20 "Modified: / 19-11-2014 / 19:59:15 / Jakub Nesveda <nesvejak@fit.cvut.cz>" |
|
21 ! ! |
|
22 |
|
23 !CustomSubContextTests methodsFor:'tests'! |
|
24 |
|
25 test_selected_methods_as_rb_method |
|
26 |
|
27 |expectedMethods realMethod actualMethods modelClass modelMethod| |
|
28 |
|
29 modelClass := model classNamed: self class name. |
|
30 modelMethod := modelClass compiledMethodAt: #test_selected_methods_as_rb_method. |
|
31 expectedMethods := Array with: modelMethod. |
|
32 |
|
33 realMethod := self class compiledMethodAt: #test_selected_methods_as_rb_method. |
|
34 context selectedMethods: (Array with: realMethod). |
|
35 actualMethods := context selectedMethods. |
|
36 |
|
37 "Cannot test coolection equality, because each contains different RBMethod instance |
|
38 self assert: expectedMethods = actualMethods" |
|
39 self assert: (expectedMethods size) = (actualMethods size). |
|
40 self assert: (expectedMethods first selector) = (actualMethods first selector). |
|
41 self assert: (expectedMethods first isKindOf: RBMethod). |
|
42 self deny: expectedMethods first isMethod |
|
43 |
|
44 "Modified: / 19-11-2014 / 20:29:40 / Jakub Nesveda <nesvejak@fit.cvut.cz>" |
|
45 ! |
|
46 |
|
47 test_selected_methods_existing_rb_method |
|
48 |
|
49 |expectedMethods actualMethods modelClass modelMethod| |
|
50 |
|
51 modelClass := model classNamed: self class name. |
|
52 modelMethod := modelClass compiledMethodAt: #test_selected_methods_as_rb_method. |
|
53 expectedMethods := Array with: modelMethod. |
|
54 |
|
55 context selectedMethods: (Array with: modelMethod). |
|
56 actualMethods := context selectedMethods. |
|
57 |
|
58 self assert: expectedMethods = actualMethods |
|
59 |
|
60 "Created: / 19-11-2014 / 20:30:39 / Jakub Nesveda <nesvejak@fit.cvut.cz>" |
|
61 ! ! |
|
62 |