Ejemplo n.º 1
0
        public async Task CreateReservationAsync_ValidObjectPassed_CreatedObject()
        {
            Reservation reservation = new Reservation()
            {
                ReservationId = 1
            };
            ReservationCreateDto reservationDto = new ReservationCreateDto();

            mockReservationRepository
            .Setup(p => p.FindByIdAsync(0))
            .ReturnsAsync(reservation);
            mockReservationRepository
            .Setup(s => s.SaveChangesAsync())
            .Verifiable();
            var service = new ReservationService(mockReservationRepository.Object, mapper);
            //Act
            var result = await service.CreateReservationAsync(reservationDto);

            //Assert
            Assert.Equal(result.ReservationId, reservation.ReservationId);
            Assert.IsType <ReservationDto>(result);
        }
Ejemplo n.º 2
0
        public async Task CreateReservation_RoomAvailable_ReservationCreated()
        {
            await reservationService.CreateReservationAsync(checkInDate, checkOutDate, guestId, roomId);

            reservationRepositoryMock.Verify(m => m.AddAsync(It.IsAny <Reservation>()), Times.Once);
        }