public async Task UpdateProfileCorrectlyRemovesOldLanguagesAndSkills()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            var candidatesRepository = new EfDeletableEntityRepository <Candidate>(context);
            var languagesRepository  = new EfDeletableEntityRepository <CandidateLanguage>(context);
            var skillsRepository     = new EfDeletableEntityRepository <CandidateSkill>(context);
            var candidatesService    = new CandidatesService(candidatesRepository, languagesRepository, skillsRepository, null);

            var candidateId = await candidatesService.CreateProfileAsync(new CreateCandidateProfileInputModel { FirstName = "Ivan", LastName = "Ivanov", ApplicationUserId = "1", LanguagesIds = new List <int> {
                                                                                                                    1
                                                                                                                }, SkillsIds = new List <int> {
                                                                                                                    1
                                                                                                                } });

            var updateModel = new UpdateCandidateProfileViewModel
            {
                LanguagesIds = new List <int> {
                    2, 3
                },
                SkillsIds = new List <int> {
                    4, 5
                },
            };

            await candidatesService.UpdateProfileAsync(candidateId, updateModel);

            var candidateLanguages = await context.Candidates
                                     .Where(c => c.Id == candidateId)
                                     .Select(c => c.Languages.Select(l => l.LanguageId).ToList())
                                     .FirstOrDefaultAsync();

            var candidateSkills = await context.Candidates
                                  .Where(c => c.Id == candidateId)
                                  .Select(c => c.Skills.Select(l => l.SkillId).ToList())
                                  .FirstOrDefaultAsync();

            Assert.Equal(2, candidateLanguages.Count);
            Assert.Equal(2, candidateSkills.Count);
            Assert.Contains(2, candidateLanguages);
            Assert.Contains(3, candidateLanguages);
            Assert.Contains(4, candidateSkills);
            Assert.Contains(5, candidateSkills);
        }