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) }); }
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; } }
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; }
public AggressivenessLevelSelected(AggressivenessLevel level) { Level = level; }
public void SetAggressivenessLevel(AggressivenessLevel level) { _eventBus.SendEvent(_responsivenessModeSelector.SetAggressivenessLevel(level)); }
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); }