public async Task FindReservationByReservationIdAsync_ShouldFindReservation() { using (var context = new ApplicationContext(options)) { var reservationService = new ReservationService(mockMapper.Object, context, mockGuestService.Object, mockRoomService.Object, mockUserService.Object, mockHotelService.Object, mockConfiguration.Object); var expected = new Reservation { ReservationStart = new DateTime(2019, 11, 10), ReservationEnd = new DateTime(2019, 11, 12), ReservationId = 1, }; var actual = await reservationService.FindReservationByReservationIdAsync(1); Assert.Equal(expected.ReservationStart, actual.ReservationStart); Assert.Equal(expected.ReservationEnd, actual.ReservationEnd); Assert.Equal(expected.ReservationId, actual.ReservationId); } }
public async Task CalculatePriceAsync_SimpleValuesShouldCalculate() { using (var context = new ApplicationContext(options)) { var reservationService = new ReservationService(mockMapper.Object, context, mockGuestService.Object, mockRoomService.Object, mockUserService.Object, mockHotelService.Object, mockConfiguration.Object); var reservation = await reservationService.FindReservationByReservationIdAsync(1); mockRoomService.Setup(x => x.FindRoomByIdAsync(1)) .Returns(Task.FromResult(new Room { RoomId = 1, Price = 400 })); int expected = 1200; var actual = await reservationService.CalculatePriceAsync(1, reservation); Assert.Equal(expected, actual); } }