コード例 #1
0
        /// <summary>
        /// Asserts that the help text <paramref name="forCommand"/> matches your <paramref name="expectedHelp"/> text
        /// </summary>
        /// <param name="expectedHelp"></param>
        /// <param name="forCommand"></param>
        private void AssertHelpIs(string expectedHelp, Type forCommand)
        {
            var cmd = new ExecuteCommandDescribeCommand(GetMockActivator().Object, forCommand);

            Assert.IsFalse(cmd.IsImpossible, cmd.ReasonCommandImpossible);

            cmd.Execute();
            StringAssert.Contains(expectedHelp, cmd.HelpShown);
        }
コード例 #2
0
        /// <summary>
        /// Asserts that the help text <paramref name="forCommand"/> matches your <paramref name="expectedHelp"/> text
        /// </summary>
        /// <param name="expectedHelp"></param>
        /// <param name="forCommand"></param>
        private void AssertHelpIs(string expectedHelp, Type forCommand)
        {
            var mock = GetMockActivator();

            var cmd = new ExecuteCommandDescribeCommand(mock.Object, forCommand);

            Assert.IsFalse(cmd.IsImpossible, cmd.ReasonCommandImpossible);

            cmd.Execute();

            string contents = Regex.Escape(expectedHelp);

            // Called once
            mock.Verify(m => m.Show(It.IsRegex(contents)), Times.Once());
        }
コード例 #3
0
        public void Test_DescribeDeleteCommand()
        {
            var mock = new Mock <IBasicActivateItems>();

            mock.Setup(m => m.RepositoryLocator).Returns(RepositoryLocator);
            mock.Setup(m => m.GetDelegates()).Returns(new List <CommandInvokerDelegate>());
            mock.Setup(m => m.Show(It.IsAny <string>()));

            var cmd = new ExecuteCommandDescribeCommand(mock.Object, typeof(ExecuteCommandDelete));

            Assert.IsFalse(cmd.IsImpossible, cmd.ReasonCommandImpossible);

            cmd.Execute();

            string contents = Regex.Escape(@"cmd Delete <deletable> 
PARAMETERS:
deletable	IDeleteable	The object you want to delete"        );

            // Called once
            mock.Verify(m => m.Show(It.IsRegex(contents)), Times.Once());
        }