コード例 #1
0
        public void HelpObserver_Update_DoesNotUpdateBotCommandStrategy(string observerTestBotCommand)
        {
            // Arrange
            IBotStrategy expectedBotCommandStrategy = null;

            // Initialize test CommandStrategy for NowObserver
            var helpCommand = new ObserverTestCommand
            {
                CommandType = CommandType.Help
            };

            IEnumerable <ICommand> commands = new List <ICommand>()
            {
                helpCommand
            };
            var commandStrategy = new BotStrategy(commands);

            // Initialize the test bot
            var helpObserver = new HelpObserver(commandStrategy);
            var testBot      = new ObserverTestBot(observerTestBotCommand, helpObserver);

            // Act
            testBot.Run();
            var actualBotCommandStrategy = testBot.Strategy;

            //Assert
            Assert.AreEqual(actualBotCommandStrategy, expectedBotCommandStrategy);
        }
コード例 #2
0
        public void HelpObserver_Update_UpdatesBotCommandStrategy()
        {
            // Arrange
            var expectedCommandStrategyIsNull = false;
            var expectedCommandType           = CommandType.Help;

            // Initialize test CommandStrategy for NowObserver
            var testHelpCommand = new ObserverTestCommand
            {
                CommandType = CommandType.Help
            };

            IEnumerable <ICommand> commands = new List <ICommand>()
            {
                testHelpCommand
            };
            var commandStrategy = new BotStrategy(commands);

            // Initialize the test bot
            var helpObserver = new HelpObserver(commandStrategy);
            var testBot      = new ObserverTestBot("/HELP", helpObserver);

            // Act
            testBot.Run();
            var actualCommandStrategyIsNull = testBot.Strategy == null;

            CommandType?actualCommandType = null;

            if (actualCommandStrategyIsNull == false)
            {
                actualCommandType = testBot.Strategy.CommandType;
            }

            //Assert
            Assert.AreEqual(actualCommandStrategyIsNull, expectedCommandStrategyIsNull);

            if (actualCommandStrategyIsNull == false)
            {
                Assert.AreEqual(actualCommandType, expectedCommandType);
            }
        }
コード例 #3
0
 private void RegisterObservers()
 {
     var joinedObserver      = new JoinedObserver(_joinedGuild);
     var helpObserver        = new HelpObserver(_messageReceived);
     var translationObserver = new TranslationObserver(_messageReceived, _config.Translator.ApiKey);
 }
コード例 #4
0
 private void RegisterObservers()
 {
     var helpObserver    = new HelpObserver(_db, _messageReceived);
     var commandObserver = new CommandObserver(_db, _messageReceived);
 }