Ejemplo n.º 1
0
        public void TestGetIdExistingAccommodation()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

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

            context.Vacancies.Add(new Vacancy()
            {
                Id              = 1,
                JobTitle        = "Test",
                AboutFunction   = "Software Engineer",
                AboutVacancy    = "Fulltime",
                City            = "Breda",
                Company         = "SPIE Nederland B.V.",
                JobRequirements = "HBO Bachelor",
                WeOffer         = "Luxe secundaire voorwaarden"
            });

            context.SaveChanges();

            IVacancyRepository repository = new EFVacancyRepository(context);

            var vacancie = repository.GetVacancy(1);

            Assert.NotNull(vacancie);
        }
Ejemplo n.º 2
0
        public void TestVacanciesFilledRepository()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

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

            context.Vacancies.AddRange(
                new Vacancy()
            {
                JobTitle = "Dit is een omschrijving", AboutFunction = "Test0"
            },
                new Vacancy()
            {
                JobTitle = "Dit is een omschrijving", AboutFunction = "Test1"
            },
                new Vacancy()
            {
                JobTitle = "Dit is een omschrijving", AboutFunction = "Test2"
            },
                new Vacancy()
            {
                JobTitle = "Dit is een omschrijving", AboutFunction = "Test3"
            }
                );
            context.SaveChanges();

            IVacancyRepository repository = new EFVacancyRepository(context);

            Assert.True(repository.Vacancies.Count() == 4);
        }
Ejemplo n.º 3
0
        public void TestVacanciesEmptyRepository()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

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

            Assert.Empty(repository.Vacancies);
        }
Ejemplo n.º 4
0
        public void TestGetIdBelowZeroVacancie()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

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

            Assert.Throws <ArgumentOutOfRangeException>(() => repository.GetVacancy(-1));
        }
Ejemplo n.º 5
0
        public void TestEmptyVacancies()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            HomeMyDayDbContext context    = new HomeMyDayDbContext(optionsBuilder.Options);
            IVacancyRepository repository = new EFVacancyRepository(context);
            IVacancyManager    manager    = new VacancyManager(repository);

            VacancyController target = new VacancyController(manager);

            var result = target.Index() as ViewResult;
            var model  = result.Model as Vacancy;

            Assert.Null(model);
        }