Exemple #1
0
        public async Task GetAllForResume_WithData_WorksCorrectly()
        {
            var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>()
                                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                 .Options);

            var expectedResults = new[] { "Major1", "Major2", "Major3" }
            .OrderBy(c => c)
            .ToArray();

            var model = new Resume()
            {
                EducationHistory = new List <Education>()
                {
                    new Education()
                    {
                        Major     = expectedResults[0],
                        Institute = "InstituteTest",
                        From      = 2000,
                        To        = 2001,
                    },
                    new Education()
                    {
                        Major     = expectedResults[1],
                        Institute = "InstituteTest",
                        From      = 2000,
                        To        = 2001,
                    },
                    new Education()
                    {
                        Major     = expectedResults[2],
                        Institute = "InstituteTest",
                        From      = 2000,
                        To        = 2001,
                    },
                }
            };

            await context.AddAsync(model);

            context.SaveChanges();

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

            var actualResults = (await educationsService.GetAllForResume(model.Id))
                                .Select(e => e.Major)
                                .OrderBy(e => e)
                                .ToArray();

            Assert.Equal(expectedResults, actualResults);
        }
Exemple #2
0
        public async Task GetAllForResume_WithNoResume_ReturnsNull()
        {
            var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>()
                                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                                 .Options);

            var model = new Resume();

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

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

            Assert.Null(result);
        }