コード例 #1
0
        public void CanRegisterCommand()
        {
            ChatCommandRouter ccr = new ChatCommandRouter();
            ChatCommand       cmd = new PrintCommand();

            ccr.Register(cmd, null);

            Assert.AreSame(cmd, ccr.GetCommand(cmd.CommandAliases()[0]).Item1);
        }
コード例 #2
0
        public void CanGetCommand()
        {
            ChatCommandRouter ccr = new ChatCommandRouter();
            ChatCommand       cmd = new PrintCommand();

            ccr.Register(cmd, null);
            ChatCommand retrievedCmd = ccr.GetCommand(cmd.CommandAliases()[0]).Item1;

            Assert.AreSame(cmd, retrievedCmd);
        }
コード例 #3
0
        async Task InitCommands(IContainer c)
        {
            c.Add <HelpCommand>();
            c.Add <AwardCommand>();
            c.Add <StatusCommand>();
            c.Add <LocaleCommand>();
            c.Add <CurrenciesCommand>();
            c.Add <LeaderboardCommand>();
            Commands = c.GetInstance <ChatCommandRouter>();
            await Commands.Start();

            foreach (IChatCommand cmd in c.GetInstances <IChatCommand>())
            {
                Commands.Add(cmd);
            }
        }
コード例 #4
0
        public void CanExecuteCommand()
        {
            ChatCommandRouter ccr = new ChatCommandRouter();
            ChatCommand       cmd = new PrintCommand();

            ccr.Register(cmd, null);

            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                string alias    = cmd.CommandAliases()[0];
                string expected = "Test Input";
                ccr.FindAndExecute($"/{alias} {expected}");

                Assert.AreEqual(expected, sw.ToString().TrimEnd());
            }
        }