Beispiel #1
0
        public async Task GetByIdAsync_WorksCorrectly()
        {
            string expectedResult = "MajorTest";

            var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>()
                                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                 .Options);

            var model = new Education()
            {
                Major     = expectedResult,
                Institute = "InstituteTest",
                From      = 2000,
                To        = 2001,
                Resume    = new Resume()
            };

            await context.AddAsync(model);

            context.SaveChanges();

            var educationsService = new EducationsService(new EfRepository <Education>(context),
                                                          new EfRepository <Resume>(context));

            var result = await educationsService.GetByIdAsync(model.Id);

            Assert.Equal(expectedResult, result.Major);
        }
Beispiel #2
0
        public async Task GetByIdAsync_WithNoExistingEducation_ReturnsNull()
        {
            string expectedResult = "MajorTest";

            var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>()
                                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                 .Options);

            var model = new Education()
            {
                Major     = expectedResult,
                Institute = "InstituteTest",
                From      = 2000,
                To        = 2001,
                Resume    = new Resume()
            };

            var educationsService = new EducationsService(new EfRepository <Education>(context),
                                                          new EfRepository <Resume>(context));

            var result = await educationsService.GetByIdAsync(model.Id);

            Assert.Null(result);
        }