Skip to content

Commit 90005ea

Browse files
committed
A couple more tests
1 parent 8cfab14 commit 90005ea

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

RubberduckTests/Commands/IndentCommandTests.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,48 @@ End Sub
175175
Assert.AreEqual(expected, project.Object.VBComponents.Item("Comp2").CodeModule.Lines());
176176
}
177177

178+
[TestMethod]
179+
public void IndentModule_CanExecute_NullActiveCodePane()
180+
{
181+
var builder = new MockVbeBuilder();
182+
VBComponent component;
183+
var vbe = builder.BuildFromSingleStandardModule("", out component);
184+
vbe.Setup(v => v.ActiveCodePane).Returns((CodePane) null);
185+
186+
var mockHost = new Mock<IHostApplication>();
187+
mockHost.SetupAllProperties();
188+
var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock<ISinks>().Object));
189+
190+
parser.Parse(new CancellationTokenSource());
191+
if (parser.State.Status >= ParserState.Error)
192+
{
193+
Assert.Inconclusive("Parser Error");
194+
}
195+
196+
var indentCommand = new IndentCurrentModuleCommand(vbe.Object, CreateIndenter(vbe.Object));
197+
Assert.IsFalse(indentCommand.CanExecute(null));
198+
}
199+
200+
[TestMethod]
201+
public void IndentModule_CanExecute()
202+
{
203+
var builder = new MockVbeBuilder();
204+
VBComponent component;
205+
var vbe = builder.BuildFromSingleStandardModule("", out component);
206+
var mockHost = new Mock<IHostApplication>();
207+
mockHost.SetupAllProperties();
208+
var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock<ISinks>().Object));
209+
210+
parser.Parse(new CancellationTokenSource());
211+
if (parser.State.Status >= ParserState.Error)
212+
{
213+
Assert.Inconclusive("Parser Error");
214+
}
215+
216+
var indentCommand = new IndentCurrentModuleCommand(vbe.Object, CreateIndenter(vbe.Object));
217+
Assert.IsTrue(indentCommand.CanExecute(null));
218+
}
219+
178220
private static IIndenter CreateIndenter(VBE vbe)
179221
{
180222
var settings = new Mock<IndenterSettings>();

0 commit comments

Comments
 (0)