public void FailToAddAlreadyAddedVehicleWhenRallyHasNotStarted()
        {
            var rally   = new Rally(2019, 2);
            var vehicle = AVehicleBuilder.BuildProperlyWorkingVehicle();

            rally.AddVehicle(vehicle);
            var operationResult = rally.AddVehicle(vehicle);

            Assert.False(operationResult.IsSuccess);
        }
        public void SucceedToAddNewVehicleWhenRallyHasNotStarted()
        {
            var rally   = new Rally(2019, 2);
            var vehicle = AVehicleBuilder.BuildProperlyWorkingVehicle();

            var operationResult = rally.AddVehicle(vehicle);

            Assert.True(operationResult.IsSuccess);
            Assert.True(rally.Vehicles.Count == 1);
        }
Exemplo n.º 3
0
        public void VehicleCannotStartRallyTwice()
        {
            var rally   = BuildRally(2);
            var vehicle = AVehicleBuilder.BuildProperlyWorkingVehicle();

            vehicle.StartRally(rally);
            Action startingRallySecondTime = () => vehicle.StartRally(rally);

            Assert.Throws <InvalidOperationException>(startingRallySecondTime);
        }
Exemplo n.º 4
0
        public async Task PassFinishLineIfWorkingProperly()
        {
            var rally   = BuildRally(2);
            var vehicle = AVehicleBuilder.BuildProperlyWorkingVehicle();

            vehicle.StartRally(rally);
            await Task.Delay(TimeSpan.FromSeconds(30));

            var vehicleStatistics = vehicle.GetStatistics();

            Assert.Equal(VehicleStatus.Finished, vehicleStatistics.Status);
            Assert.NotNull(vehicleStatistics.FinishTime);
            Assert.True(rally.Distance <= vehicleStatistics.DistanceFromStart);
        }