예제 #1
0
        private async void OnRentExecute()
        {
            var selectedCar = SelectedCar;

            var preflight = await _preflightService.Preflight(SelectedCar.Model);

            if (preflight.Code == PreflightResultCode.BLOCKED)
            {
                _messageDialogService.ShowInfoDialog(preflight.Message);
                Cars.Remove(SelectedCar);
                SelectedCar = null;
                return;
            }

            var result = _messageDialogService.ShowOkCancelDialog(preflight.Message, "Confirmation");

            if (result == MessageDialogResult.OK)
            {
                var booking = new Booking {
                    CarId = SelectedCar.Model.Id, UserId = _currentUser.Id, RentedAt = DateTime.Now
                };
                _bookingRepository.MakeRent(booking);
                await _bookingRepository.SaveAsync();

                Cars.Remove(SelectedCar);
                SelectedCar = null;
                _messageDialogService.ShowInfoDialog($"You successfuly rented {selectedCar.Name}");
            }
        }
예제 #2
0
        public async Task ShouldBlockedIfRented()
        {
            _bookingRepository.HasRentAsync(Arg.Any <int>()).Returns(true);

            var car = new Car {
                Name = "TestCar"
            };

            var result = await _preflightService.Preflight(car);

            Assert.AreEqual(PreflightResultCode.BLOCKED, result.Code);

            Assert.AreEqual(string.Format(PreflightResultMessage.BLOCKED, car.Name), result.Message);

            StringAssert.DoesNotContain(string.Format(PreflightResultMessage.APPROVE, car.Name), result.Message);
        }