コード例 #1
0
        public void TestFilledSearchAccommodations()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            HomeMyDayDbContext context = new HomeMyDayDbContext(optionsBuilder.Options);

            context.Accommodations.Add(new Accommodation()
            {
                Beds        = 4,
                Continent   = "Europe",
                Country     = "Netherlands",
                Description = "Van der Valk hotels",
                Location    = "Gilze",
                MaxPersons  = 4,
                Name        = "Van der valk Gilze",
                Rooms       = 5
            });

            context.SaveChanges();

            IAccommodationRepository repository = new EFAccommodationRepository(context);
            IReviewRepository        reviewRepo = new EFReviewRepository(context, repository);
            IAccommodationManager    manager    = new AccommodationManager(repository, reviewRepo);

            SearchBarViewComponent target = new SearchBarViewComponent(manager);

            AccommodationSearchViewModel results = (AccommodationSearchViewModel)(target.Invoke() as ViewViewComponentResult).ViewData.Model;

            Assert.NotNull(results);
            Assert.NotEmpty(results.Accommodations);
        }
コード例 #2
0
        public void TestEmptySearchAccommodations()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            HomeMyDayDbContext       context    = new HomeMyDayDbContext(optionsBuilder.Options);
            IAccommodationRepository repository = new EFAccommodationRepository(context);
            IReviewRepository        reviewRepo = new EFReviewRepository(context, repository);
            IAccommodationManager    manager    = new AccommodationManager(repository, reviewRepo);

            SearchBarViewComponent target = new SearchBarViewComponent(manager);

            AccommodationSearchViewModel results = (AccommodationSearchViewModel)(target.Invoke() as ViewViewComponentResult).ViewData.Model;

            Assert.NotNull(results);
            Assert.Empty(results.Accommodations);
        }