示例#1
0
        public void ReturnLeaderBoardForVehicleType(Vehicle vehicle1, Vehicle vehicle2, Vehicle vehicle3, VehicleType vehicleType)
        {
            var vehicles = RaceBuilder.BuildWithVehicles(vehicle1, vehicle2, vehicle3).LeaderBoardForVehicleType(vehicleType);

            var vehiclesAllTheSameType = vehicles.All(v => v.Type.Equals(vehicleType));

            vehiclesAllTheSameType.Should().BeTrue();
        }
示例#2
0
        public void FindVehiclesByModelAndStatus(string model, string vehicleStatus)
        {
            var vehicle1 = VehicleBuilder.BuildWithTeamNameAndModelAndStatus("Koksha", "187", VehicleStatus.Pending);
            var vehicle2 = VehicleBuilder.BuildWithTeamNameAndModelAndStatus("Nino", "187", VehicleStatus.Pending);

            var vehicles = RaceBuilder.BuildWithVehicles(vehicle1, vehicle2).FindVehicleBy(string.Empty, model, vehicleStatus);

            vehicles.Should().HaveCount(2);
        }
示例#3
0
        public void ReturnAllVehiclesLeaderBoard(Vehicle vehicle1, Vehicle vehicle2, Vehicle vehicle3)
        {
            var vehicles = RaceBuilder.BuildWithVehicles(vehicle1, vehicle2, vehicle3).AllVehiclesLeaderBoard();

            vehicles.Should().HaveCount(3);
            vehicles.Should().Contain(vehicle1);
            vehicles.Should().Contain(vehicle2);
            vehicles.Should().Contain(vehicle3);
        }
示例#4
0
        public void ThrowExceptionIfTheTeamNameIsAlreadyTakenWhenAddingNewCarToTheRace()
        {
            var vehicle      = VehicleBuilder.Build();
            var vehicleToAdd = VehicleBuilder.BuildUpsertVehicleWithId(vehicle.Id);
            var race         = RaceBuilder.BuildWithVehicles(vehicle);

            Exception ex = Assert.Throws <Exception>(() => race.AddVehicle(vehicleToAdd));

            ex.Message.Should().Be($"Team name '{vehicleToAdd.TeamName}' is already taken.");
        }
示例#5
0
        public void FindVehiclesByStatus(string vehicleStatus)
        {
            var vehicle1 = VehicleBuilder.BuildWithTeamNameAndModelAndStatus("Koksha", "Peugeot", VehicleStatus.Pending);
            var vehicle2 = VehicleBuilder.BuildWithTeamNameAndModelAndStatus("Nino", "Subaru", VehicleStatus.Pending);
            var vehicle3 = VehicleBuilder.BuildWithTeamNameAndModelAndStatus("Tibika", "Citroen", VehicleStatus.Running);

            var vehicles = RaceBuilder.BuildWithVehicles(vehicle1, vehicle2).FindVehicleBy(string.Empty, string.Empty, vehicleStatus);

            vehicles.Should().HaveCount(2);
        }
示例#6
0
        public void FindOneVehicleWhenAllThreeSearchParametersAreEntered(string teamName, string model, string vehicleStatus)
        {
            var vehicle1 = VehicleBuilder.Build();
            var vehicle2 = VehicleBuilder.BuildWithTeamNameAndModelAndStatus("Koksha", "187", VehicleStatus.Pending);
            var vehicle3 = VehicleBuilder.BuildWithTeamNameAndModelAndStatus("Nino", "187", VehicleStatus.Pending);

            var vehicles = RaceBuilder.BuildWithVehicles(vehicle1, vehicle2, vehicle3).FindVehicleBy(teamName, model, vehicleStatus);

            vehicles.Should().HaveCount(1);
        }
示例#7
0
        public void ThrowExceptionIfTheTeamNameIsAlreadyTakenWhileTryingToUpdateVehicleInfo()
        {
            var vehicle         = VehicleBuilder.Build();
            var vehicleToUpdate = VehicleBuilder.BuildUpsertVehicleWithId(vehicle.Id);
            var race            = RaceBuilder.BuildWithVehicles(vehicle);

            Exception ex = Assert.Throws <Exception>(() => race.UpdateVehicleInfo(vehicleToUpdate));

            ex.Message.Should().Be($"Team name '{vehicleToUpdate.TeamName}' is already taken.");
        }
示例#8
0
        public void ReturnVehicleStatistics()
        {
            var vehicle  = VehicleBuilder.Build();
            var vehicle2 = VehicleBuilder.BuildWithVehicleStatusAndDistanceAndFinishTime(VehicleStatus.Finished, 250, "20:33");

            var vehicleStatistics = RaceBuilder.BuildWithVehicles(vehicle, vehicle2).VehicleStatisticsBy(vehicle.Id);

            vehicleStatistics.Distance.Should().Be(vehicle.Distance);
            vehicleStatistics.Status.Should().Be(vehicle.Status);
            vehicleStatistics.FinishTime.Should().Be(vehicle.FinishTime);
        }
示例#9
0
        public void StartRace()
        {
            var checkRaceProgressionInSeconds = 10;
            var vehicle  = VehicleBuilder.Build();
            var vehicle2 = VehicleBuilder.Build();

            var race = RaceBuilder.BuildWithVehicles(vehicle, vehicle2).StartRace(checkRaceProgressionInSeconds);

            var vehiclesStatusIsNotPending = race.Vehicles.All(v => v.Status != VehicleStatus.Pending);

            race.Status.Should().NotBe(RaceStatusType.Pending);
            race.Vehicles.Should().NotBeEmpty();
            vehiclesStatusIsNotPending.Should().BeTrue();
        }