public void IndentModule_IndentsModule() { var input = @" Option Explicit ' at least I used it... Sub InverseIndent() Dim d As Boolean Dim s As Integer End Sub Sub RandomIndent() Dim d As Boolean Dim s As Integer End Sub "; var expected = @"Option Explicit ' at least I used it... Sub InverseIndent() Dim d As Boolean Dim s As Integer End Sub Sub RandomIndent() Dim d As Boolean Dim s As Integer End Sub "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("Proj1", vbext_ProjectProtection.vbext_pp_none) .AddComponent("Comp1", vbext_ComponentType.vbext_ct_ClassModule, input) .AddComponent("Comp2", vbext_ComponentType.vbext_ct_ClassModule, input) .Build(); var vbe = builder.AddProject(project).Build(); vbe.Setup(s => s.ActiveCodePane).Returns(project.Object.VBComponents.Item("Comp2").CodeModule.CodePane); var mockHost = new Mock <IHostApplication>(); mockHost.SetupAllProperties(); var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object)); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var indentCommand = new IndentCurrentModuleCommand(vbe.Object, CreateIndenter(vbe.Object)); indentCommand.Execute(null); Assert.AreEqual(input, project.Object.VBComponents.Item("Comp1").CodeModule.Lines()); Assert.AreEqual(expected, project.Object.VBComponents.Item("Comp2").CodeModule.Lines()); }
public void IndentModule_CanExecute() { IVBComponent component; var vbe = MockVbeBuilder.BuildFromSingleStandardModule("", out component); var state = MockParser.CreateAndParse(vbe.Object); var indentCommand = new IndentCurrentModuleCommand(vbe.Object, CreateIndenter(vbe.Object), state); Assert.IsTrue(indentCommand.CanExecute(null)); }
public void IndentModule_IndentsModule() { var input = @" Option Explicit ' at least I used it... Sub InverseIndent() Dim d As Boolean Dim s As Integer End Sub Sub RandomIndent() Dim d As Boolean Dim s As Integer End Sub "; var expected = @"Option Explicit ' at least I used it... Sub InverseIndent() Dim d As Boolean Dim s As Integer End Sub Sub RandomIndent() Dim d As Boolean Dim s As Integer End Sub "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("Proj1", ProjectProtection.Unprotected) .AddComponent("Comp1", ComponentType.ClassModule, input) .AddComponent("Comp2", ComponentType.ClassModule, input) .Build(); var vbe = builder.AddProject(project).Build(); vbe.Setup(s => s.ActiveCodePane).Returns(project.Object.VBComponents["Comp2"].CodeModule.CodePane); using (var state = MockParser.CreateAndParse(vbe.Object)) { var indentCommand = new IndentCurrentModuleCommand(vbe.Object, CreateIndenter(vbe.Object), state); indentCommand.Execute(null); var module1 = project.Object.VBComponents["Comp1"].CodeModule; var module2 = project.Object.VBComponents["Comp2"].CodeModule; Assert.AreEqual(input, module1.Content()); Assert.AreEqual(expected, module2.Content()); } }
public void IndentModule_CanExecute_NullActiveCodePane() { IVBComponent component; var vbe = MockVbeBuilder.BuildFromSingleStandardModule("", out component); vbe.Setup(v => v.ActiveCodePane).Returns((ICodePane)null); using (var state = MockParser.CreateAndParse(vbe.Object)) { var indentCommand = new IndentCurrentModuleCommand(vbe.Object, CreateIndenter(vbe.Object), state); Assert.IsFalse(indentCommand.CanExecute(null)); } }
public void IndentModule_CanExecute() { var builder = new MockVbeBuilder(); VBComponent component; var vbe = builder.BuildFromSingleStandardModule("", out component); var mockHost = new Mock <IHostApplication>(); mockHost.SetupAllProperties(); var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object)); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var indentCommand = new IndentCurrentModuleCommand(vbe.Object, CreateIndenter(vbe.Object)); Assert.IsTrue(indentCommand.CanExecute(null)); }
public IndentCurrentModuleCommandMenuItem(IndentCurrentModuleCommand command) : base(command) { }