static void PrintState(EventFeedStateMachine stateMachine) => Console.WriteLine($"Current state: {stateMachine.State.ToString()}");
static void PrintExceptionsReceived(EventFeedStateMachine stateMachine) => Console.WriteLine($"Exceptions received: {stateMachine.ExceptionsReceived}");
static void Main(string[] args) { var stateMachine = new EventFeedStateMachine(threshold: 3); /* Current state: Normal */ PrintState(stateMachine); Console.WriteLine(); /* * Exception occurred * Exceptions received: 1 * Current state: Exception */ PrintExceptionOccurred(); stateMachine.ExceptionOccurred(new Exception()); PrintExceptionsReceived(stateMachine); PrintState(stateMachine); Console.WriteLine(); /* * Exception occurred * Exceptions received: 2 * Current state: Exception */ PrintExceptionOccurred(); stateMachine.ExceptionOccurred(new Exception()); PrintExceptionsReceived(stateMachine); PrintState(stateMachine); Console.WriteLine(); /* * Exception occurred * Exceptions received: 2 * Current state: Exception */ PrintExceptionOccurred(); stateMachine.ExceptionOccurred(new Exception()); PrintExceptionsReceived(stateMachine); PrintState(stateMachine); Console.WriteLine(); /* * Successful dispatch * Current state: Normal */ PrintSuccessfulDispatch(); stateMachine.SuccessfulDispatch(); PrintState(stateMachine); Console.WriteLine(); /* * Exception occurred * Exceptions received: 1 * Current state: Exception */ PrintExceptionOccurred(); stateMachine.ExceptionOccurred(new Exception()); PrintExceptionsReceived(stateMachine); PrintState(stateMachine); Console.WriteLine(); /* * Successful dispatch * Current state: Normal */ PrintSuccessfulDispatch(); stateMachine.SuccessfulDispatch(); PrintState(stateMachine); Console.ReadLine(); }