Example #1
0
        public void ExchangeRateObserver_Update_DoesNotUpdateBotCommandStrategy(string observerTestBotCommand)
        {
            // Arrange
            IBotStrategy expectedBotCommandStrategy = null;

            // Initialize test CommandStrategy for ExchangeRateObserver
            var testExchangeRateCommand = new ObserverTestCommand
            {
                CommandType = CommandType.ExchangeRate
            };

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

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

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

            //Assert
            Assert.AreEqual(actualBotCommandStrategy, expectedBotCommandStrategy);
        }
Example #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);
            }
        }
Example #3
0
        public void ExchangeRateObserver_Update_UpdatesBotCommandStrategy()
        {
            // Arrange
            var expectedCommandStrategyIsNull = false;
            var expectedCommandType           = CommandType.ExchangeRate;

            // Initialize test CommandStrategy for ExchangeRateObserver
            var testExchangeRateCommand = new ObserverTestCommand
            {
                CommandType = CommandType.ExchangeRate
            };

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

            // Initialize the test bot
            var exchangeRateObserver = new ExchangeRateObserver(commandStrategy);
            var testBot = new ObserverTestBot("/EXCHANGERATE", exchangeRateObserver);

            // 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);
            }
        }
        public void ShowCurrListBYObserver_Update_UpdatesBotCommandStrategy()
        {
            // Arrange
            var expectedCommandStrategyIsNull = false;
            var expectedCommandType           = CommandType.ShowCurrListBY;

            // Initialize test CommandStrategy for NowObserver
            var testShowCurrListBYCommand = new ObserverTestCommand
            {
                CommandType = CommandType.ShowCurrListBY
            };

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

            // Initialize the test bot
            var showCurrListBYObserver = new ShowCurrListBYObserver(commandStrategy);
            var testBot = new ObserverTestBot("/SHOWCURRLISTBY", showCurrListBYObserver);

            // 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);
            }
        }