private int GetOpponentsInFront(List <CheckpointProgressTracker> opponentRaceCars) { int opponentsInFront = 0; for (int i = 0; i < opponentRaceCars.Count; i++) { if (RaceHelperFuntions.IsOpponentInFront(opponentRaceCars[i].RaceStats, RaceStats)) { opponentsInFront++; } } return(opponentsInFront); }
public void ShouldBeBehindOpponentWhenOpponentHasPassedCheckerPriorToFirstLapAndDriverHasNot() { var opponentDriver = new RaceStats( ZERO_LAPS_ELAPSED_PASSED_CHECKER_FLAG, TARGET_CHECKPOINT_TWO, TOTAL_CHECKPOINTS, NEAR_TARGET_CHECKPOINT); var testDriver = new RaceStats( ZERO_LAPS_ELAPSED, TARGET_CHECKPOINT_TWO, TOTAL_CHECKPOINTS, NEAR_TARGET_CHECKPOINT); bool shouldBeTrue = RaceHelperFuntions.IsOpponentInFront(opponentDriver, testDriver); Assert.IsTrue(shouldBeTrue); }
public void ShouldBeInfrontOfOpponentOnFirstLap() { var opponentDriver = new RaceStats( ZERO_LAPS_ELAPSED, TARGET_CHECKPOINT_TWO, TOTAL_CHECKPOINTS, NEAR_TARGET_CHECKPOINT); var testDriver = new RaceStats( ZERO_LAPS_ELAPSED, TARGET_CHECKPOINT_TREE, TOTAL_CHECKPOINTS, NEAR_TARGET_CHECKPOINT); bool shouldBeFalse = RaceHelperFuntions.IsOpponentInFront(opponentDriver, testDriver); Assert.IsFalse(shouldBeFalse); }
public void ShouldInCorrectOrder() { var inFirstPositionDriver = new RaceStats( ZERO_LAPS_ELAPSED_PASSED_CHECKER_FLAG, TARGET_CHECKPOINT_TREE, TOTAL_CHECKPOINTS, FIRST_POSITION_DISTANCE_TO_CHECKPOINT); var inSecondPositionDriver = new RaceStats( ZERO_LAPS_ELAPSED_PASSED_CHECKER_FLAG, TARGET_CHECKPOINT_TWO, TOTAL_CHECKPOINTS, SECOND_POSITION_DISTANCE_TO_CHECKPOINT); var inThirdPositionDriver = new RaceStats( ZERO_LAPS_ELAPSED_PASSED_CHECKER_FLAG, TARGET_CHECKPOINT_TWO, TOTAL_CHECKPOINTS, THIRD_POSITION_DISTANCE_TO_CHECKPOINT); bool firstShouldBeInFrontOfSecond = RaceHelperFuntions.IsOpponentInFront(inFirstPositionDriver, inSecondPositionDriver); bool firstShouldBeInFrontOfThird = RaceHelperFuntions.IsOpponentInFront(inFirstPositionDriver, inThirdPositionDriver); bool secondShouldBeInFrontOfThrid = RaceHelperFuntions.IsOpponentInFront(inSecondPositionDriver, inThirdPositionDriver); bool thirdShouldBeBehindFirst = RaceHelperFuntions.IsOpponentInFront(inFirstPositionDriver, inThirdPositionDriver); bool thirdShouldBeBehindSecond = RaceHelperFuntions.IsOpponentInFront(inSecondPositionDriver, inThirdPositionDriver); Assert.IsTrue(firstShouldBeInFrontOfSecond); Assert.IsTrue(firstShouldBeInFrontOfThird); Assert.IsTrue(secondShouldBeInFrontOfThrid); Assert.IsTrue(thirdShouldBeBehindFirst); Assert.IsTrue(thirdShouldBeBehindSecond); }