Beispiel #1
0
        public async Task TestEditReservation()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());

            var reservationRepository = new EfDeletableEntityRepository <Reservation>(new ApplicationDbContext(options.Options));
            var reservationId         = Guid.NewGuid().ToString();

            var guests   = new List <Guest>();
            var guestOne = new Guest
            {
                FirstName   = "Petar",
                LastName    = "Stoqnov",
                PhoneNumber = "0888888888",
                CreatedOn   = DateTime.UtcNow,
            };
            var guestTwo = new Guest
            {
                FirstName   = "Dimitar",
                LastName    = "Neykov",
                PhoneNumber = "0888888888",
                CreatedOn   = DateTime.UtcNow.AddDays(-1),
            };

            guests.Add(guestOne);
            guests.Add(guestTwo);

            await reservationRepository.AddAsync(new Reservation
            {
                Id          = reservationId,
                ArrivalDate = DateTime.UtcNow,
                Guests      = guests,
            });

            await reservationRepository.SaveChangesAsync();

            var reservationsService = new ReservationsService(reservationRepository);

            await reservationsService.UpdateAsync(Guid.NewGuid().ToString(), reservationId, 1,
                                                  DateTime.UtcNow.AddDays(1), DateTime.UtcNow, 1, 1, "Georgi",
                                                  "Petrov", "0888989844", null, 10.00M, true, false, false);

            var result = reservationRepository.All().FirstOrDefault();

            Assert.Equal(DateTime.UtcNow.AddDays(1).Date, result.ArrivalDate.Date);
        }