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

            var expectedResults = new[] { "Skill1", "Skill2", "Skill3" }
            .OrderBy(c => c)
            .ToArray();

            var model = new Resume()
            {
                Skills = new List <Skill>()
                {
                    new Skill()
                    {
                        Name = expectedResults[0]
                    },
                    new Skill()
                    {
                        Name = expectedResults[1]
                    },
                    new Skill()
                    {
                        Name = expectedResults[2]
                    },
                }
            };

            await context.AddAsync(model);

            context.SaveChanges();

            var skillService = new SkillService(new EfRepository <Resume>(context),
                                                new EfRepository <Skill>(context));

            var actualResults = (await skillService.GetAllForResume(model.Id))
                                .Select(s => s.Name)
                                .OrderBy(s => s)
                                .ToArray();

            Assert.Equal(expectedResults, actualResults);
        }