示例#1
0
 private void ShiftUpGears(int gearShifts, GearBox gearBox)
 {
     gearBox.DoIt(0); //from neutral to first gear
     for (int i = 1; i < gearShifts; i++)
     {
         gearBox.DoIt(int.MaxValue);
     }
 }
示例#2
0
        public void ShiftFrom1To2WithSpecificRpm()
        {
            ShiftUpGears(1, _gearbox);
            var boundaryForGear1 = _rpmUpDictionary[1];

            _gearbox.DoIt(boundaryForGear1 + 1);
            var resultAfterDoIt = _gearbox.S();

            Assert.Equal(2, resultAfterDoIt);
        }
示例#3
0
        public void GearBoxCreatedWithoutDictionaryCanShiftUp()
        {
            var gearBox = new GearBox();

            gearBox.DoIt(0);
            var result = gearBox.S();

            Assert.Equal(1, result);
        }
示例#4
0
        private void ShiftsDownWithRpmLowerThanThreshold(IDictionary <int, int> downDictionary, int startingGear)
        {
            //arrange
            var upDictionary = DefaultUpDict();
            var gearBox      = new GearBox(upDictionary, downDictionary);

            ShiftUpGears(startingGear, gearBox);

            //action
            gearBox.DoIt(downDictionary[startingGear] - 1);
            var result       = gearBox.S();
            var expectedGear = startingGear - 1;

            Assert.Equal(expectedGear, result);
        }