CustomCodeSelectionToResourceTranslationTests.st
author Jakub Nesveda <jakubnesveda@seznam.cz>
Mon, 25 Aug 2014 23:45:19 +0200
changeset 645 38a38c28ddb1
child 650 7514c13d6dd8
permissions -rw-r--r--
work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation

"{ 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>"
! !