コード例 #1
0
        private static AutomatedActionSystem SetUpTestActionSystem(params IIntervalAction[] actions)
        {
            var intervalActions      = new List <IIntervalAction>(actions);
            var automateActionSystem = new AutomatedActionSystem(intervalActions, new FakeClock());

            return(automateActionSystem);
        }
コード例 #2
0
 public HangmanGame(CurrencyGenerator currencyGenerator, AutomatedActionSystem automatedActionSystem,
                    List <string> wordList)
 {
     _currencyGenerator     = currencyGenerator;
     _automatedActionSystem = automatedActionSystem;
     _wordList = wordList;
 }
コード例 #3
0
ファイル: BotMain.cs プロジェクト: MisterJames/devchatterbot
        private readonly int _refreshInterval = 1000;//the milliseconds the bot waits before checking for new messages

        public BotMain(List <IChatClient> chatClients, IRepository repository, CommandHandler commandHandler,
                       SubscriberHandler subscriberHandler, FollowableSystem followableSystem, AutomatedActionSystem automatedActionSystem)
        {
            _chatClients           = chatClients;
            _repository            = repository;
            _commandHandler        = commandHandler;
            _subscriberHandler     = subscriberHandler;
            _followableSystem      = followableSystem;
            _automatedActionSystem = automatedActionSystem;
        }
コード例 #4
0
ファイル: SetUpBot.cs プロジェクト: MisterJames/devchatterbot
        public static BotMain NewBot(TwitchClientSettings twitchSettings, string connectionString)
        {
            var twitchApi        = new TwitchAPI(twitchSettings.TwitchClientId);
            var twitchChatClient = new TwitchChatClient(twitchSettings, twitchApi);
            var chatClients      = new List <IChatClient>
            {
                new ConsoleChatClient(),
                twitchChatClient,
            };
            var twitchFollowerService = new TwitchFollowerService(twitchApi, twitchSettings);

            IRepository repository = SetUpDatabase.SetUpRepository(connectionString);

            var chatUserCollection = new ChatUserCollection(repository);
            var currencyGenerator  = new CurrencyGenerator(chatClients, chatUserCollection);
            var currencyUpdate     = new CurrencyUpdate(1, currencyGenerator);

            var automatedActionSystem = new AutomatedActionSystem(new List <IIntervalAction> {
                currencyUpdate
            });
            var rockPaperScissorsGame = new RockPaperScissorsGame(currencyGenerator, automatedActionSystem);
            var wordList = new List <string> {
                "apple", "banana", "orange", "mango", "watermellon", "grapes", "pizza", "pasta", "pepperoni", "cheese", "mushroom", "csharp", "javascript", "cplusplus", "nullreferenceexception", "parameter", "argument"
            };
            var hangmanGame = new HangmanGame(currencyGenerator, automatedActionSystem, wordList);

            var simpleCommands = repository.List <SimpleCommand>();

            List <IBotCommand> allCommands = new List <IBotCommand>();

            allCommands.AddRange(simpleCommands);
            allCommands.Add(new GiveCommand(chatUserCollection));
            allCommands.Add(new HelpCommand(allCommands));
            allCommands.Add(new CommandsCommand(allCommands));
            allCommands.Add(new CoinsCommand(repository));
            allCommands.Add(new BonusCommand(currencyGenerator));
            allCommands.Add(new StreamsCommand(repository));
            allCommands.Add(new ShoutOutCommand(twitchFollowerService));
            allCommands.Add(new QuoteCommand(repository));
            allCommands.Add(new AddQuoteCommand(repository));
            allCommands.Add(new AddCommandCommand(repository, allCommands));
            allCommands.Add(new RemoveCommandCommand(repository, allCommands));
            allCommands.Add(new HangmanCommand(hangmanGame));
            allCommands.Add(new RockPaperScissorsCommand(rockPaperScissorsGame));

            var commandHandler    = new CommandHandler(chatClients, allCommands);
            var subscriberHandler = new SubscriberHandler(chatClients);

            var twitchSystem = new FollowableSystem(new[] { twitchChatClient }, twitchFollowerService);


            var botMain = new BotMain(chatClients, repository, commandHandler, subscriberHandler, twitchSystem, automatedActionSystem);

            return(botMain);
        }
コード例 #5
0
        public void InvokeNoActions_GivenNoReadyActions()
        {
            var mock = new Mock <IIntervalAction>();
            AutomatedActionSystem automateActionSystem = SetUpTestActionSystem(mock.Object, mock.Object);

            mock.Setup(x => x.IsTimeToRun()).Returns(false);

            automateActionSystem.RunNecessaryActions();

            mock.Verify(x => x.Invoke(), Times.Never());
        }
コード例 #6
0
        public void InvokeAction_GivenOneReadyAction()
        {
            var mock = new Mock <IIntervalAction>();
            AutomatedActionSystem automateActionSystem = SetUpTestActionSystem(mock.Object);

            mock.Setup(x => x.IsTimeToRun()).Returns(true);

            automateActionSystem.RunNecessaryActions();

            mock.Verify(x => x.Invoke(), Times.Once());
        }
コード例 #7
0
        public void InvokeOnlyReadyActions_GivenMultipleStatesOfActions()
        {
            var mock1 = new Mock <IIntervalAction>();
            var mock2 = new Mock <IIntervalAction>();
            AutomatedActionSystem automateActionSystem = SetUpTestActionSystem(mock1.Object, mock2.Object);

            mock1.Setup(x => x.IsTimeToRun()).Returns(true);
            mock2.Setup(x => x.IsTimeToRun()).Returns(false);

            automateActionSystem.RunNecessaryActions();

            mock1.Verify(x => x.Invoke(), Times.Once());
            mock2.Verify(x => x.Invoke(), Times.Never());
        }
コード例 #8
0
        public void InvokeNoActions_GivenNoActions()
        {
            AutomatedActionSystem automateActionSystem = SetUpTestActionSystem(new IIntervalAction[0]);

            automateActionSystem.RunNecessaryActions();
        }
コード例 #9
0
 public RockPaperScissorsGame(CurrencyGenerator currencyGenerator, AutomatedActionSystem automatedActionSystem)
 {
     _currencyGenerator     = currencyGenerator;
     _automatedActionSystem = automatedActionSystem;
 }