Skip to content

Commit

Permalink
Bugfix: Interactive Mode does not work correctly (+Tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf committed May 30, 2012
1 parent 8561f23 commit 39dde60
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/shell.me/ShellMe.Console.Tests/CommandInitTests.cs
Expand Up @@ -34,15 +34,33 @@ public void SetsBooleanCommandProperties()
}

[Test]
public void RunsIndefinetlyInInteractiveMode()
public void RunsTwoTimesInteractiveAndThenClosesAfterLastNonInteractive()
{
var console = new TestConsole(new List<string>() { "--test", "exit" });
var console = new TestConsole(new List<string>() { "--test --interactive", "--test" });
var commandFactory = new CommandFactory(new[] { new TestCommand() });
var commandLoop = new CommandLoop(console, commandFactory);
commandLoop.Start(new[] { "--test", "--IsTest", "--interactive" });

Assert.AreEqual("Run with Test", console.OutputQueue[0]);
Assert.AreEqual("Enter commands or type exit to close", console.OutputQueue[1]);
Assert.AreEqual("Run", console.OutputQueue[2]);
Assert.AreEqual("Enter commands or type exit to close", console.OutputQueue[3]);
Assert.AreEqual("Run", console.OutputQueue[4]);
Assert.AreEqual(5, console.OutputQueue.Count);
}

[Test]
public void RunsTwoTimesInteractiveAndThenIgnoresLastCommandBecauseOfPreviousExit()
{
var console = new TestConsole(new List<string>() { "--test --interactive", "exit", "--test" });
var commandFactory = new CommandFactory(new[] { new TestCommand() });
var commandLoop = new CommandLoop(console, commandFactory);
commandLoop.Start(new[] { "--test", "--IsTest", "--interactive" });

Assert.AreEqual("Run with Test", console.OutputQueue[0]);
Assert.AreEqual("Enter commands or type exit to close", console.OutputQueue[1]);
Assert.AreEqual("Run", console.OutputQueue[2]);
Assert.AreEqual("Enter commands or type exit to close", console.OutputQueue[3]);
Assert.AreEqual(4, console.OutputQueue.Count);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/shell.me/ShellMe.Console/CommandLoop.cs
Expand Up @@ -64,6 +64,7 @@ public void Start(string[] args)
var tempArgs = input.Split(' ');
command = _commandFactory.GetCommand(new CommandMatcher(tempArgs).CommandName);
TryToProceedCommand(command, tempArgs);
interactive = command.Interactive;
}
}
}
Expand Down

0 comments on commit 39dde60

Please sign in to comment.