public async Task TestGetByIdReservationFromHotel() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var reservationRepository = new EfDeletableEntityRepository <Reservation>(new ApplicationDbContext(options.Options)); var reservationId = Guid.NewGuid().ToString(); await reservationRepository.AddAsync(new Reservation { Id = reservationId, Room = new Room { Number = "100", HotelId = 1, }, }); await reservationRepository.AddAsync(new Reservation { Id = Guid.NewGuid().ToString(), Room = new Room { Number = "200", HotelId = 1, }, }); await reservationRepository.AddAsync(new Reservation { Id = Guid.NewGuid().ToString(), Room = new Room { Number = "300", HotelId = 2, }, }); await reservationRepository.SaveChangesAsync(); var reservationsService = new ReservationsService(reservationRepository); AutoMapperConfig.RegisterMappings(typeof(MyTestReservation).Assembly); var reservation = await reservationsService.GetByIdAsync <MyTestReservation>(reservationId); Assert.Equal("100", reservation.RoomNumber); }