Example #1
0
        public void ListCommand()
        {
            IServiceProvider provider = GetServiceProvider();
            ICommandFinder   finder   = GetCommandFinder(provider);

            List <string> commands = new ();
            ICommand      command  = finder.GetCommand("list", belongsTo: typeof(SpecificCommandSet));

            command.Execute(commands);

            this.testOutputHelper.WriteLine(string.Join(Environment.NewLine, commands));

            Assert.Collection(
                commands.OrderBy(x => x),
                cmdDetails => Assert.Equal("Usage: bye", cmdDetails.Substring(0, 10)),
                cmdDetails => Assert.Equal("Usage: say", cmdDetails.Substring(0, 10))
                );
        }
Example #2
0
        public void NullCommand()
        {
            IServiceProvider provider = GetServiceProvider();
            ICommandFinder   finder   = GetCommandFinder(provider);
            string           someCommandWhichRlyDonTExists = "some command which rly don't exists";
            ICommand         command = finder.GetCommand(someCommandWhichRlyDonTExists);

            Assert.IsType <NullCommand>(command);
            Assert.Equal(string.Empty, command.GetDetails());
            Assert.Equal(someCommandWhichRlyDonTExists, ((NullCommand)command).RequestedCommandName);

            try
            {
                command.Execute(true, string.Empty, new object(), 1, 1.1);
                Assert.True(true);
            }
            catch (Exception)
            {
                Assert.True(false);
            }
        }