Permalink
Browse files

Adding test for CmdCommando

  • Loading branch information...
manojlds committed Dec 16, 2012
1 parent 4146ce2 commit 5f4539afec308689ef41e6382c3f17374bd66909
Showing with 39 additions and 0 deletions.
  1. +38 −0 src/cmd.UnitTests/Commands/CmdCommandoTests.cs
  2. +1 −0 src/cmd.UnitTests/cmd.UnitTests.csproj
@@ -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"));
+ }
+ }
+}
@@ -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" />

0 comments on commit 5f4539a

Please sign in to comment.