CustomCodeSelectionToResourceTranslationTests.st
changeset 698 525d39491ecc
parent 688 6bd18ba5e56c
child 704 340954b48789
--- a/CustomCodeSelectionToResourceTranslationTests.st	Wed Oct 15 07:51:12 2014 +0200
+++ b/CustomCodeSelectionToResourceTranslationTests.st	Thu Oct 16 21:31:15 2014 +0200
@@ -15,6 +15,48 @@
 
 !CustomCodeSelectionToResourceTranslationTests methodsFor:'tests'!
 
+test_available_in_code_view_perspective
+    | perspective |
+
+    perspective := CustomPerspective codeViewPerspective.
+
+    self assert: (generatorOrRefactoring class availableInPerspective:perspective).
+
+    "Created: / 15-10-2014 / 08:10:35 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_available_in_context_empty
+    
+    self deny: (generatorOrRefactoring class availableInContext: context).
+
+    "Modified: / 15-10-2014 / 09:32:27 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_available_in_context_empty_selected_codes
+
+    context selectedCodes: (Array
+        with: CustomSourceCodeSelection new  
+    ).
+
+    self deny: (generatorOrRefactoring class availableInContext: context).
+
+    "Created: / 15-10-2014 / 09:37:41 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_available_in_context_with_selected_codes
+
+    context selectedCodes: (Array
+        with: (CustomSourceCodeSelection new
+            selectedInterval: (1 to: 5);
+            currentSourceCode: 'selector_05 ^ 5';
+            yourself)
+    ).
+
+    self assert: (generatorOrRefactoring class availableInContext: context).
+
+    "Created: / 15-10-2014 / 09:41:44 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
 test_code_selection_replaced_by_resource_translation_01
     | expectedSource originalSource codeSelection class |
 
@@ -44,5 +86,45 @@
 
     "Created: / 23-08-2014 / 20:09:06 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
     "Modified: / 26-08-2014 / 23:13:22 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_code_selection_replaced_by_resource_translation_02
+    | expectedSource originalSource codeSelection class |
+
+    originalSource := 'selector
+    self information: self theInformation.
+    ^ self.'.
+
+    class := model createClassImmediate: 'DummyClassForTestCase01' instanceVariableNames: 'resources'.
+    model createMethodImmediate: class source: originalSource.
+
+    codeSelection := CustomSourceCodeSelection new.
+    codeSelection
+        currentSourceCode: originalSource;
+        selectedClass: class;
+        selectedInterval: (32 to: 51);
+        selectedMethod: (class compiledMethodAt: #selector);
+        selectedSelector: #selector.
+
+    context selectedCodes: (Array with: codeSelection).  
+    generatorOrRefactoring executeInContext: context.  
+
+    expectedSource := 'selector
+    self information:(resources string:self theInformation).
+    ^ self.'.
+
+    self assertMethodSource:expectedSource atSelector:#selector forClass:class
+
+    "Created: / 15-10-2014 / 09:45:08 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_not_available_in_class_perspective
+    | perspective |
+
+    perspective := CustomPerspective classPerspective.
+
+    self deny: (generatorOrRefactoring class availableInPerspective:perspective).
+
+    "Created: / 15-10-2014 / 08:11:43 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
 ! !