public void NewGuestHostReservation_Success()
        {
            Guest newGuest = new Guest();

            newGuest.Id = _guestsRepo.GetNumberOfGuests() + 1;
            ActionResult <Guest> guestActionResult = _guestsController.CreateGuest(newGuest);

            Assert.IsTrue(guestActionResult.Result is CreatedAtRouteResult);

            HostCreateDto newHost = new HostCreateDto();

            newHost.Apartment                 = new ApartmentCreateDto();
            newHost.Apartment.Address         = new Address();
            newHost.Apartment.Address.Country = "Israel";
            newHost.Apartment.Address.City    = "Netanya";
            newHost.Apartment.Address.Street  = "Beeri";
            ActionResult <HostReadDto> hostActionResult = _hostsController.CreateHost(newHost);

            Assert.IsTrue(hostActionResult.Result is CreatedAtRouteResult);
            CreatedAtRouteResult hostReadDto = hostActionResult.Result as CreatedAtRouteResult;

            ReservationCreateDto newReservations = new ReservationCreateDto();

            newReservations.ArrivingDate       = new DateTime(2018, 08, 01);
            newReservations.LeavingDate        = new DateTime(2018, 08, 09);
            newReservations.ReservationGuestId = newGuest.Id;
            newReservations.ReservationHostId  = ((HostReadDto)hostReadDto.Value).Id;
            ActionResult <ReservationReadDto> reservationSctionResult = _reservationsController.CreateReservation(newReservations);

            Assert.IsTrue(reservationSctionResult.Result is CreatedAtRouteResult);
        }
示例#2
0
        public void CreateGuest_ShouldCreateGuest()
        {
            Guest newGuest = new Guest();

            newGuest.Id = _repo.GetNumberOfGuests() + 1;
            ActionResult <Guest> actionResult = _controller.CreateGuest(newGuest);

            Assert.IsTrue(actionResult.Result is CreatedAtRouteResult);
        }