public void Test1()
 {
     _stateMachine.Start();
     _stateMachine.Current.Should().Be(ChargingState.Charging, "we can start immediatly after creation");
     _stateMachine.Stop();
     _stateMachine.Current.Should().Be(ChargingState.NotCharging, "we can stop immediatly after starting");
     _stateMachine.Start();
     _stateMachine.Current.Should().Be(ChargingState.Charging, "we can start immediatly after stopping");
 }
Пример #2
0
        protected (bool allow, bool changed) AllowToCharge()
        {
            bool stateHasChanged;

            if (_state.Current == ChargingState.Charging)
            {
                return(true, false);
            }

            if (_state.Current == ChargingState.ChargingPaused)
            {
                stateHasChanged = _state.Unpause();
                if (stateHasChanged)
                {
                    LoggerState.Info($"Charging state unpaused");
                }
            }
            else
            {
                stateHasChanged = _state.Start();
                LoggerState.Info($"Charging state start");
            }

            return(stateHasChanged, stateHasChanged);
        }