public void TestAddVehicleReservationOk()
        {
            DateTime checkOut = DateTime.Now.AddDays(7);

            _reservationAutomobile =
                EntityFactory.CreateReservationVehicle(0, DateTime.Now, checkOut, 5, _user.Id);
            _reservationAutomobile = dao.AddReservation(_reservationAutomobile);
            Assert.NotZero(_reservationAutomobile.Id);
        }
示例#2
0
        /// <summary>
        /// Guarda una reservación de vehículo en la base de datos mediente el DAO de reservación de vehículo
        /// </summary>
        /// <exception cref="ReservationHasNoUserException">Se retorna cuando el ID del usaurio es menor o igual a 0</exception>
        /// <exception cref="ReservationHasNoVehicleException">Se retorna cuando el ID del vehiculo es menor o igual a 0</exception>
        /// <exception cref="ReservationHasNoCheckInException">Se retorna cuando no se recibe la fecha de checkin</exception>
        /// <exception cref="ReservationHasNoCheckOutException">Se retorna cuando no se revibe la fecha de checkout</exception>
        public void Execute()
        {
            if (_reservationAutomobile.UserId <= 0)
            {
                throw new ReservationHasNoUserException();
            }
            if (_reservationAutomobile.VehicleId <= 0)
            {
                throw new ReservationHasNoVehicleException();
            }
            if (_reservationAutomobile.CheckIn.Equals(DateTime.MinValue))
            {
                throw new ReservationHasNoCheckInException();
            }
            if (_reservationAutomobile.CheckOut.Equals(DateTime.MinValue))
            {
                throw new ReservationHasNoCheckOutException();
            }

            IReservationVehicleDAO dao = DAOFactory.GetFactory(DAOFactory.Type.Postgres).GetReservationVehicleDAO();

            _reservationAutomobile = dao.AddReservation(_reservationAutomobile);
        }