From 5f4539afec308689ef41e6382c3f17374bd66909 Mon Sep 17 00:00:00 2001 From: Manoj Mahalingam Date: Mon, 17 Dec 2012 00:37:33 +0530 Subject: [PATCH] Adding test for CmdCommando --- .../Commands/CmdCommandoTests.cs | 38 +++++++++++++++++++ src/cmd.UnitTests/cmd.UnitTests.csproj | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/cmd.UnitTests/Commands/CmdCommandoTests.cs diff --git a/src/cmd.UnitTests/Commands/CmdCommandoTests.cs b/src/cmd.UnitTests/Commands/CmdCommandoTests.cs new file mode 100644 index 0000000..768bc81 --- /dev/null +++ b/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 mockRunner; + private dynamic cmd; + + [SetUp] + public void SetUp() + { + mockRunner = new Mock(); + 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())).Callback(options => + { + expectedRunOptions + = options; + }); + + cmd.dir(); + + Assert.That(expectedRunOptions.Command, Is.EqualTo("cmd")); + Assert.That(expectedRunOptions.Arguments, Is.EqualTo("/c dir")); + } + } +} \ No newline at end of file diff --git a/src/cmd.UnitTests/cmd.UnitTests.csproj b/src/cmd.UnitTests/cmd.UnitTests.csproj index 0eced20..1061d6a 100644 --- a/src/cmd.UnitTests/cmd.UnitTests.csproj +++ b/src/cmd.UnitTests/cmd.UnitTests.csproj @@ -47,6 +47,7 @@ +