コード例 #1
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());
        }
コード例 #2
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());
        }
コード例 #3
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());
        }
コード例 #4
0
ファイル: BotMain.cs プロジェクト: MisterJames/devchatterbot
        private void BeginLoop()
        {
            _stopRequestSource = new CancellationTokenSource();
            Task.Run(() =>
            {
                while (_stopRequestSource.Token.IsCancellationRequested != true)
                {
                    Thread.Sleep(_refreshInterval);

                    _automatedActionSystem.RunNecessaryActions();

                    _autoMsgSystem.CheckMessages();

                    while (_autoMsgSystem.DequeueMessage(out string message))
                    {
                        foreach (var chatClient in _chatClients)
                        {
                            chatClient.SendMessage(message);
                        }
                    }
                }
            });
        }
コード例 #5
0
        public void InvokeNoActions_GivenNoActions()
        {
            AutomatedActionSystem automateActionSystem = SetUpTestActionSystem(new IIntervalAction[0]);

            automateActionSystem.RunNecessaryActions();
        }