Example #1
0
        public void TestGetReviewByAccommodationOk()
        {
            Review review1 = new Review()
            {
                Id        = 1,
                Comment   = "Prueba1",
                Score     = 3,
                BookingId = 1
            };
            Review review2 = new Review()
            {
                Id        = 3,
                Comment   = "Prueba12",
                Score     = 4,
                BookingId = 2
            };
            List <Review> reviews = new List <Review>()
            {
                review1,
                review2
            };

            _context.Add(
                new Accommodation()
            {
                Id   = 1,
                Name = "a"
            }
                );
            _context.Add(
                new Accommodation()
            {
                Id   = 2,
                Name = "b"
            }
                );
            _context.Add(new Booking
            {
                Id = 1,
                AccommodationId = 1,
                BookingHistory  = new List <BookingStage>(),
                CheckIn         = DateTime.Now,
                CheckOut        = DateTime.Now.AddDays(3),
                GuestId         = 2,
                Guests          = new List <Guest>(),
                HeadGuest       = new Tourist()
                {
                    Email = "*****@*****.**"
                },
                TotalPrice = 35
            });
            _context.Add(new Booking
            {
                Id = 2,
                AccommodationId = 1,
                BookingHistory  = new List <BookingStage>(),
                CheckIn         = DateTime.Now,
                CheckOut        = DateTime.Now.AddDays(3),
                GuestId         = 2,
                Guests          = new List <Guest>(),
                HeadGuest       = new Tourist()
                {
                    Email = "*****@*****.**"
                },
                TotalPrice = 35
            });
            _context.Add(new Booking
            {
                Id = 3,
                AccommodationId = 2,
                BookingHistory  = new List <BookingStage>(),
                CheckIn         = DateTime.Now,
                CheckOut        = DateTime.Now.AddDays(3),
                GuestId         = 2,
                Guests          = new List <Guest>(),
                HeadGuest       = new Tourist()
                {
                    Email = "*****@*****.**"
                },
                TotalPrice = 35
            });
            _context.Add(new Review()
            {
                Id        = 2,
                Comment   = "Prueba123",
                Score     = 1,
                BookingId = 3
            });
            reviews.ForEach(r => _context.Add(r));
            _context.SaveChanges();
            var repository = new ReviewRepository(_context);

            var result = repository.GetByAccommodation(1);

            Assert.IsTrue(reviews.SequenceEqual(result));
        }