Skip to content

Commit

Permalink
Adding test for CmdCommando
Browse files Browse the repository at this point in the history
  • Loading branch information
manojlds committed Dec 16, 2012
1 parent 4146ce2 commit 5f4539a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/cmd.UnitTests/Commands/CmdCommandoTests.cs
@@ -0,0 +1,38 @@
using Moq;
using NUnit.Framework;
using cmd.Commands;
using cmd.Runner;

namespace cmd.UnitTests.Commands
{
[TestFixture]
public class CmdCommandoTests
{
private Mock<IRunner> mockRunner;
private dynamic cmd;

[SetUp]
public void SetUp()
{
mockRunner = new Mock<IRunner>();
mockRunner.Setup(runner => runner.GetCommand()).Returns(new CmdCommando(mockRunner.Object));
cmd = new Cmd(mockRunner.Object);
}

[Test]
public void ShouldRunTheCommandAgainstCmd()
{
IRunOptions expectedRunOptions = null;
mockRunner.Setup(runner => runner.Run(It.IsAny<IRunOptions>())).Callback<IRunOptions>(options =>
{
expectedRunOptions
= options;
});

cmd.dir();

Assert.That(expectedRunOptions.Command, Is.EqualTo("cmd"));
Assert.That(expectedRunOptions.Arguments, Is.EqualTo("/c dir"));
}
}
}
1 change: 1 addition & 0 deletions src/cmd.UnitTests/cmd.UnitTests.csproj
Expand Up @@ -47,6 +47,7 @@
<ItemGroup>
<Compile Include="CmdDSLTests.cs" />
<Compile Include="CmdTests.cs" />
<Compile Include="Commands\CmdCommandoTests.cs" />
<Compile Include="Commands\CommandoTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Runner\Arguments\ArgumentBuilderTests.cs" />
Expand Down

0 comments on commit 5f4539a

Please sign in to comment.