Exemple #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);
        }
Exemple #2
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);
            }
        }