CustomCodeSelectionToResourceTranslationTests.st
changeset 645 38a38c28ddb1
child 650 7514c13d6dd8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CustomCodeSelectionToResourceTranslationTests.st	Mon Aug 25 23:45:19 2014 +0200
@@ -0,0 +1,48 @@
+"{ Package: 'jn:refactoring_custom' }"
+
+CustomCodeGeneratorOrRefactoringTestCase subclass:#CustomCodeSelectionToResourceTranslationTests
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-Refactoring-Custom-Tests'
+!
+
+!CustomCodeSelectionToResourceTranslationTests methodsFor:'accessing'!
+
+generatorOrRefactoring
+    ^ CustomCodeSelectionToResourceTranslation new
+! !
+
+!CustomCodeSelectionToResourceTranslationTests methodsFor:'tests'!
+
+test_code_selection_replaced_by_resource_translation_01
+    | expectedSource originalSource codeSelection class |
+
+    originalSource := 'selector
+    self information: ''Translate this''.
+    ^ self.'.
+
+    class := codeBuilder createClassImmediate: 'DummyClassForTestCase01' instanceVariableNames: 'resources'.
+    codeBuilder createMethodImmediate: class source: originalSource.
+
+    codeSelection := CustomSourceCodeSelection new.
+    codeSelection
+        currentSourceCode: originalSource;
+        selectedClass: class;
+        selectedInterval: (32 to: 48);
+        selectedMethod: (class compiledMethodAt: #selector);
+        selectedSelector: #selector.
+
+    context selectedCodes: (Array with: codeSelection).  
+    generatorOrRefactoring executeInContext: context.  
+
+    expectedSource := 'selector
+    self information: (resources string: (''Translate this'')).
+    ^ self.'.
+
+    self assertMethodSource:expectedSource atSelector:#selector
+
+    "Created: / 23-08-2014 / 20:09:06 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+    "Modified: / 24-08-2014 / 09:52:39 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+! !
+