public void shouldReturnNewMethod()
            {
                var inputCode = @"
Option Explicit
Private Sub Foo()
    Dim x As Integer
    x = 1 + 2
End Sub";

                QualifiedModuleName qualifiedModuleName;

                using (var state = MockParser.ParseString(inputCode, out qualifiedModuleName))
                {
                    var declarations = state.AllDeclarations;

                    var SUT = new ExtractedMethod();

                    var expected = "NewMethod";
                    //Act
                    var actual = SUT.getNewMethodName(declarations);

                    //Assert

                    Assert.AreEqual(expected, actual);
                }
            }
예제 #2
0
            public void shouldReturnAnIncrementedMethodName()
            {
                QualifiedModuleName   qualifiedModuleName;
                RubberduckParserState state;

                #region inputCode
                var inputCode = @"
Option Explicit
Private Sub Foo()
    Dim x As Integer
    x = 1 + 2
End Sub
Private Sub NewMethod
    dim a as string
    Debug.Print a
End Sub";
                #endregion inputCode

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

                var SUT = new ExtractedMethod();

                var expected = "NewMethod1";
                //Act
                var actual = SUT.getNewMethodName(declarations);

                //Assert
                Assert.AreEqual(expected, actual);
            }
            public void shouldReturnAnLeastNextMethod()
            {
                #region inputCode
                var inputCode = @"
Option Explicit
Private Sub Foo()
    Dim x As Integer
    x = 1 + 2
End Sub
Private Sub NewMethod
    dim a as string
    Debug.Print a
End Sub
Private Sub NewMethod1
    dim a as string
    Debug.Print a
End Sub
Private Sub NewMethod4
    dim a as string
    Debug.Print a
End Sub";
                #endregion inputCode

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

                    var SUT = new ExtractedMethod();

                    var expected = "NewMethod2";
                    //Act
                    var actual = SUT.getNewMethodName(declarations);

                    //Assert
                    Assert.AreEqual(expected, actual);
                }
            }