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()); }
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()); }
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()); }
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); } } } }); }
public void InvokeNoActions_GivenNoActions() { AutomatedActionSystem automateActionSystem = SetUpTestActionSystem(new IIntervalAction[0]); automateActionSystem.RunNecessaryActions(); }