public IReadOnlyCollection <IEvent> SetAggressivenessLevel(AggressivenessLevel level)
        {
            if (_currentAggressivenessLevel == level)
            {
                throw new DomainRuleViolatedException("This aggressiveness level was already selected");
            }

            _currentAggressivenessLevel = level;

            return(new List <IEvent> {
                new AggressivenessLevelSelected(level)
            });
        }
Esempio n. 2
0
        public void ApplyEvent(IEvent @event)
        {
            switch (@event)
            {
            case AggressivenessLevelSelected aggressivenessLevel:
                AggressivenessLevel = aggressivenessLevel.Level;
                break;

            case GearChanged gearChanged:
                if (gearChanged.EnteredGear.Value < gearChanged.PreviousGear.Value && AggressivenessLevel == AggressivenessLevel.Third)
                {
                    _eventBus.SendEvent(new ExhaustExplosionOccured());
                }
                break;
            }
        }
Esempio n. 3
0
        public void ApplyEvent(IEvent @event)
        {
            switch (@event)
            {
            case ComfortModeEntered _:
                CurrentResponsivenessMode = ResponsivenessMode.Comfort;
                break;

            case EconomicModeEntered _:
                CurrentResponsivenessMode = ResponsivenessMode.Economic;
                break;

            case SportModeEntered _:
                CurrentResponsivenessMode = ResponsivenessMode.Sport;
                break;

            case AggressivenessLevelSelected aggressivenessLevel:
                CurrentAggressivenessLevel = aggressivenessLevel.Level;
                break;
            }

            UpdateCurrentMode();
        }
 public ResponsivenessModeSelector()
 {
     _currentMode = ResponsivenessMode.Comfort;
     _currentAggressivenessLevel = AggressivenessLevel.First;
 }
Esempio n. 5
0
 public AggressivenessLevelSelected(AggressivenessLevel level)
 {
     Level = level;
 }
Esempio n. 6
0
 public void SetAggressivenessLevel(AggressivenessLevel level)
 {
     _eventBus.SendEvent(_responsivenessModeSelector.SetAggressivenessLevel(level));
 }
Esempio n. 7
0
 public ShiftpointRange GetRangeFor(ResponsivenessMode responsivenessMode, AggressivenessLevel aggressivenessLevel)
 => _rangeForMode[responsivenessMode].AsModifiedBy(_bumpPercentageForAggressivenessLevel[aggressivenessLevel]);
        public void ReturnsProperRangeForModeAndAggressivenessLevel(ResponsivenessMode selectedMode, AggressivenessLevel selectedAggressiveness, double lowerShiftPoint, double upperShiftPoint)
        {
            var characteristics = new EngineCharacteristics();

            var characteristicsRange = characteristics.GetRangeFor(selectedMode, selectedAggressiveness);

            Assert.AreEqual(lowerShiftPoint, characteristicsRange.LowerShiftPoint.Value);
            Assert.AreEqual(upperShiftPoint, characteristicsRange.UpperShiftPoint.Value);
        }