コード例 #1
0
        public void VerticalSpacing_IndentProcedureDoesntRemoveSurroundingWhitespace()
        {
            const string inputCode =
                @"Type Foo
    Bar As Long
End Type

Function TestFunction() As Long
TestFunction = 42
End Function

Sub TestSub()
End Sub";

            const string expectedCode =
                @"Type Foo
    Bar As Long
End Type

Function TestFunction() As Long
    TestFunction = 42
End Function

Sub TestSub()
End Sub";

            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component, new Selection(6, 1));

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var indentCommand = new IndentCurrentProcedureCommand(vbe.Object, new Indenter(vbe.Object, () => IndenterSettingsTests.GetMockIndenterSettings()), state);
                indentCommand.Execute(null);
                Assert.AreEqual(expectedCode, component.CodeModule.Content());
            }
        }
コード例 #2
0
        public void VerticalSpacing_IgnoredWithIndentProcedureExtraSpacing()
        {
            string expected;
            var    input = expected =
                @"Private Sub TestOne()
End Sub


Private Sub TestTwo()
End Sub


Private Sub TestThree()
End Sub";

            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(input, out var component, new Selection(3, 5, 3, 5));

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var indenter = new Indenter(vbe.Object, () =>
                {
                    var s = IndenterSettingsTests.GetMockIndenterSettings();
                    s.VerticallySpaceProcedures = true;
                    s.LinesBetweenProcedures    = 1;
                    return(s);
                });
                var indentCommand = new IndentCurrentProcedureCommand(vbe.Object, indenter, state);
                indentCommand.Execute(null);

                Assert.AreEqual(expected, component.CodeModule.Content());
            }
        }
コード例 #3
0
 public IndentCurrentProcedureCommandMenuItem(IndentCurrentProcedureCommand command) : base(command)
 {
 }