public void shouldNotProduceDuplicateDimOfz()
        {
            #region inputCode
            var inputCode = @"
Option explicit
Public Sub CodeWithDeclaration()
    Dim x as long
    Dim y as long

    x = 1 + 2
    DebugPrint x                      '8
    y = x + 1
    Dim z as long
    z = x  
    DebugPrint z                      '12
    x = 2
    DebugPrint y


End Sub                                '17
Public Sub DebugPrint(byval g as long)
End Sub
                                       '20

";

            var selectedCode = @"
    DebugPrint x                      '8
    y = x + 1
    Dim z as long
    z = x  
    DebugPrint z                      '12
";
            var expectedCode = @"
Option explicit
Public Sub CodeWithDeclaration()
    Dim x as long
    Dim y as long

    x = 1 + 2
NewMethod x, y
    x = 2
    DebugPrint y


End Sub                                '17
Private Sub NewMethod(ByRef x As long, ByRef y As long) 
    Dim z as long
    DebugPrint x                      '8
    y = x + 1
    z = x  
    DebugPrint z                      '12
End Sub
Public Sub DebugPrint(byval g as long)
End Sub
                                       '20

";
            #endregion

            QualifiedModuleName   qualifiedModuleName;
            RubberduckParserState state;
            MockParser.ParseString(inputCode, out qualifiedModuleName, out state);
            var declarations = state.AllDeclarations;

            var selection = new Selection(8, 1, 12, 50);
            QualifiedSelection?qSelection = new QualifiedSelection(qualifiedModuleName, selection);

            List <IExtractMethodRule> emRules = new List <IExtractMethodRule>()
            {
                new ExtractMethodRuleInSelection(),
                new ExtractMethodRuleIsAssignedInSelection(),
                new ExtractMethodRuleUsedBefore(),
                new ExtractMethodRuleUsedAfter(),
                new ExtractMethodRuleExternalReference()
            };

            var codeModule      = new CodeModuleWrapper(qualifiedModuleName.Component.CodeModule);
            var extractedMethod = new ExtractedMethod();
            var paramClassify   = new ExtractMethodParameterClassification(emRules);
            var model           = new ExtractMethodModel(extractedMethod, paramClassify);
            model.extract(declarations, qSelection.Value, selectedCode);

            var SUT = new ExtractMethodExtraction();

            //Act
            SUT.apply(codeModule, model, selection);

            //Assert
            var actual = codeModule.get_Lines(1, 1000);
            Assert.AreEqual(expectedCode, actual);
        }