public void TestAddNotExistingReview() { var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>(); optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); HomeMyDayDbContext context = new HomeMyDayDbContext(optionsBuilder.Options); IAccommodationRepository accommodationRepository = new EFAccommodationRepository(context); context.Accommodations.Add(new Accommodation() { Id = 1, Name = "TestAccommodation", Beds = 6, Country = "Amsterdam", Rooms = 3 }); context.SaveChanges(); IReviewRepository repository = new EFReviewRepository(context, accommodationRepository); Assert.True(repository.AddReview(1, "Review Holiday 001", "TestReview", "De vakantie was goed!")); Assert.True(repository.GetAccomodationReviews(1).Count() == 1); }
public void TestAddArgumentOutOfRangeExceptionReview() { var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>(); optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); HomeMyDayDbContext context = new HomeMyDayDbContext(optionsBuilder.Options); IAccommodationRepository accommodationRepository = new EFAccommodationRepository(context); context.Accommodations.Add(new Accommodation() { Id = 1, Name = "TestAccommodation", Beds = 6, Country = "Amsterdam", Rooms = 3 }); context.SaveChanges(); IReviewRepository repository = new EFReviewRepository(context, accommodationRepository); Assert.Throws <ArgumentOutOfRangeException>(() => repository.AddReview(0, null, null, null)); }