Ejemplo n.º 1
0
        public async Task ScenarioOkay01TestAsync()
        {
            var dateVon     = new DateTime(2019, 12, 14);
            var dateBis     = new DateTime(2019, 12, 15);
            var reservation = await _target.GetReservationById(1);

            reservation.Von = dateVon;
            reservation.Bis = dateBis;
            await _target.UpdateReservation(reservation);
        }
Ejemplo n.º 2
0
        public IActionResult CancelReservation([FromRoute] string id)
        {
            var userVm = _reservationManager.GetReservationById(id);

            _reservationManager.CancelReservationAsync(userVm.Result);
            return(RedirectToAction("Details", "User", new { id = userVm.Result.User.Id }));
        }
Ejemplo n.º 3
0
        public async Task UpdateReservationTest()
        {
            var reservation = await _target.GetReservationById(4);

            var von = new DateTime(2019, 12, 24);
            var bis = new DateTime(2019, 12, 28);

            reservation.Von = von;
            reservation.Bis = bis;
            await _target.UpdateReservation(reservation);

            var result = await _target.GetReservationById(4);

            Assert.Equal(von, result.Von);
            Assert.Equal(bis, result.Bis);
        }
        public void TestExactlylongReservation()
        {
            Reservation res = ReservationManager.GetReservationById(1);

            res.Von = DateTime.Today;
            res.Bis = DateTime.Today.AddDays(100);
            ReservationManager.UpdateReservation(res);
        }
        public void TestWrongYear()
        {
            Reservation res = ReservationManager.GetReservationById(1);

            res.Von = new DateTime(2030, 1, 1);
            res.Bis = new DateTime(1999, 1, 1);
            var ex = Assert.Throws <FaultException <InvalidDateRangeFault> >(
                () => ReservationManager.UpdateReservation(res)
                );

            Assert.Equal(ReservationManager.vonNachBisMessage, ex.Detail.Message);
        }
        public void TestVonAfterBis()
        {
            Reservation res = ReservationManager.GetReservationById(1);

            res.Von = DateTime.Today.AddDays(1);
            res.Bis = DateTime.Today;
            var ex = Assert.Throws <FaultException <InvalidDateRangeFault> >(
                () => ReservationManager.UpdateReservation(res)
                );

            Assert.Equal(ReservationManager.vonNachBisMessage, ex.Detail.Message);
        }
        public void TestNot24h()
        {
            Reservation res = ReservationManager.GetReservationById(1);

            res.Von = DateTime.Today;
            res.Bis = DateTime.Today.AddHours(12);



            var ex = Assert.Throws <FaultException <InvalidDateRangeFault> >(
                () => ReservationManager.UpdateReservation(res)
                );

            Assert.Equal(ReservationManager.min24hMessage, ex.Detail.Message);
        }
Ejemplo n.º 8
0
        public void UpdateReservationTest()
        {
            Reservation res = ReservationManager.GetReservationById(1);

            res.Von     = DateTime.Today.AddDays(20);
            res.Bis     = DateTime.Today.AddDays(30);;
            res.KundeId = 2;
            res.AutoId  = 3;
            ReservationManager.UpdateReservation(res);

            Reservation sameRes = ReservationManager.GetReservationById(1);

            Assert.Equal(2, sameRes.KundeId);
            Assert.Equal(3, sameRes.AutoId);
            Assert.Equal(DateTime.Today.AddDays(30), sameRes.Bis);
        }
Ejemplo n.º 9
0
        public void TestOK2()
        {
            //                                   ------------1-------------
            //         ------------2-------------
            Reservation res = ReservationManager.GetReservationById(1);

            res.Von = DateTime.Today.AddDays(2);
            res.Bis = DateTime.Today.AddDays(3);
            ReservationManager.UpdateReservation(res);

            Reservation res2 = ReservationManager.GetReservationById(2);

            res2.Von = DateTime.Today.AddDays(1);
            res2.Bis = DateTime.Today.AddDays(2);

            ReservationManager.UpdateReservation(res2);
        }
Ejemplo n.º 10
0
        public ReservationDto ReadReservationDto(int id)
        {
            WriteActualMethod();

            try
            {
                return(_reservationManager.GetReservationById(id).ConvertToDto());
            }

            catch (InvalidOperationException)
            {
                OutOfRangeFault fault = new OutOfRangeFault()
                {
                    Operation = "Read"
                };
                throw new FaultException <OutOfRangeFault>(fault);
            }
        }
        public async Task <ActionResult> Delete(string Id)
        {
            try
            {
                var reservation = await reservationManager.GetReservationById(Id);

                if (reservation != null)
                {
                    await reservationManager.DeleteReservation(reservation);

                    return(Ok());
                }
                else
                {
                    return(NotFound("Reservation not found"));
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 12
0
        public void TestOverlap4()
        {
            //          ------------1-------------
            //      ----------------2-----------------
            Reservation res = ReservationManager.GetReservationById(1);

            res.Von = DateTime.Today.AddDays(1);
            res.Bis = DateTime.Today.AddDays(2);
            int targetCarId = res.AutoId;

            ReservationManager.UpdateReservation(res);

            Reservation res2 = ReservationManager.GetReservationById(2);

            res2.Von    = DateTime.Today;
            res2.Bis    = DateTime.Today.AddDays(5);
            res2.AutoId = targetCarId;

            Assert.Throws <FaultException <AutoUnavailableFault> >(
                () => ReservationManager.UpdateReservation(res2)
                );
        }
Ejemplo n.º 13
0
        public async Task ScenarioOkay01Test()
        {
            var reservation1 = await _target.GetReservationById(1);

            //| ---Date 1--- |
            var date1von = new DateTime(2019, 10, 20);
            var date1bis = new DateTime(2019, 12, 24);
            //               | ---Date 2--- |
            var reservation2 = await _target.GetReservationById(2);

            var date2von = new DateTime(2019, 12, 24);
            var date2bis = new DateTime(2020, 1, 5);

            reservation1.Von = date1von;
            reservation1.Bis = date1bis;
            reservation2.Von = date2von;
            reservation2.Bis = date2bis;
            // act
            async Task Act1() => await _target.UpdateReservation(reservation1);
            async Task Act2() => await _target.UpdateReservation(reservation2);

            // assert
            Assert.Equal(reservation2.Von, reservation1.Bis);
        }
Ejemplo n.º 14
0
 public ReservationDto GetReservationDtoById(int Id)
 {
     WriteActualMethod();
     return(ReservationManager.GetReservationById(Id).ConvertToDto());
 }
Ejemplo n.º 15
0
        public override async Task <ReservationDto> GetReservationenById(GetReservationRequest request, ServerCallContext context)
        {
            ReservationDto response = await reservationenManager.GetReservationById(request.Id).ConvertToDto();

            return(response ?? throw new RpcException(new Status(StatusCode.NotFound, "ID is invalid.")));
        }
Ejemplo n.º 16
0
        public async Task GetMeetingRoom()
        {
            var meetingRoom = await reservationManager.GetReservationById(NewReservation.ID);

            Assert.IsNotNull(meetingRoom);
        }