public async Task UpdateAsyncReturnsNullWhenRecordNotInDatabase()
        {
            AutoMapperInitializer.InitializeMapper();
            var context    = InMemoryDbContextInitializer.InitializeContext();
            var repository = new EfDeletableEntityRepository <JobOffer>(context);
            var service    = this.GetMockedService(repository);

            var model = new EditViewModel
            {
                JobOfferDetails = new EditJobOfferDetailsModel
                {
                    Id           = "4444",
                    LanguagesIds = new List <int> {
                        4, 5,
                    },
                    SkillsIds = new List <int> {
                        6, 7
                    },
                    JobTypesIds = new List <int> {
                        8, 9, 1
                    },
                    JobLevelId  = 2,
                    JobSectorId = 3,
                    City        = "New York",
                    Position    = "CEO",
                },
            };

            var result = await service.UpdateAsync(model, "1");

            Assert.Null(result);
        }
Пример #2
0
        public async Task IfLogoIsInvalidCreateProfileReturnsNull()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();

            var repository       = new EfDeletableEntityRepository <Employer>(context);
            var cloudinary       = new Cloudinary(new Account(CloudinaryConfig.CloudName, CloudinaryConfig.ApiKey, CloudinaryConfig.ApiSecret));
            var employersService = this.GetMockedService(repository, cloudinary);

            var logo  = this.PrepareInvalidImage();
            var model = new CreateEmployerProfileInputModel
            {
                ApplicationUserId = "1",
                Name = "Recruit Me",
                ContactPersonNames       = "Ivan Ivanov",
                ContactPersonEmail       = "*****@*****.**",
                JobSectorId              = 4,
                UniqueIdentificationCode = "204558718",
                Logo = logo,
            };

            var employerId = await employersService.CreateProfileAsync(model);

            Assert.Null(employerId);
        }
Пример #3
0
        public async Task UpdateAsyncCorrectlyUpdatesInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Skills.AddRangeAsync(this.SeedData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <Skill>(context);

            var service = new SkillsService(repository);

            var model = new EditViewModel
            {
                Name      = "NewName",
                IsDeleted = true,
            };

            var result = await service.UpdateAsync(1, model);

            Assert.NotEqual(-1, result);

            var dbRecord = await context.Skills.FindAsync(1);

            Assert.NotEqual("First", dbRecord.Name);
            Assert.NotNull(dbRecord.DeletedOn);
            Assert.True(dbRecord.IsDeleted);
        }
        public async Task IfProfilePictureIsNotNullCreateProfileSavesCorrectLink()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();

            var candidateRepository = new EfDeletableEntityRepository <Candidate>(context);
            var cloudinary          = new Cloudinary(new Account(CloudinaryConfig.CloudName, CloudinaryConfig.ApiKey, CloudinaryConfig.ApiSecret));
            var candidatesService   = this.GetMockedService(candidateRepository, null, null, cloudinary);

            var profilePicture = this.PrepareImage();

            var model = new CreateCandidateProfileInputModel
            {
                FirstName         = "Ivan",
                LastName          = "Ivanov",
                ApplicationUserId = "1",
                ProfilePicture    = profilePicture,
            };

            var candidateId = await candidatesService.CreateProfileAsync(model);

            Assert.NotNull(candidateId);

            var pictureUrl = context.Candidates.Find(candidateId).ProfilePictureUrl;

            Assert.NotNull(pictureUrl);
            Assert.Contains(model.ApplicationUserId + "_profilePicture", pictureUrl);

            CloudinaryService.DeleteFile(cloudinary, model.ApplicationUserId + "_profilePicture");
        }
Пример #5
0
        ApplySavesTheRecordCorrectly()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.ApplicationStatuses.AddAsync(new JobApplicationStatus { Name = "Under Review", Id = 1 });

            await context.SaveChangesAsync();

            var repository          = new EfDeletableEntityRepository <JobApplication>(context);
            var documentsRepository = new EfDeletableEntityRepository <JobApplicationDocument>(context);
            var jobOffersRepository = new Mock <EfDeletableEntityRepository <JobOffer> >(context);

            jobOffersRepository.Setup(r => r.AllAsNoTracking()).Returns(new List <JobOffer>
            {
                new JobOffer
                {
                    Id       = "333",
                    Position = "CEO",
                    Employer = new Employer
                    {
                        ContactPersonEmail = "email",
                        ContactPersonNames = "Georgi Georgiev",
                        ApplicationUser    = new ApplicationUser
                        {
                            Email = "OtherEmail"
                        },
                    },
                },
            }.AsQueryable());

            var service = this.GetMockedService(repository, documentsRepository, jobOffersRepository.Object);

            var model = new ApplyViewModel
            {
                JobOfferId       = "333",
                CandidateId      = "1",
                CandidateDetails = new CandidateContactDetailsViewModel
                {
                    ApplicationUserEmail = "userEmail",
                    FirstName            = "Ivan",
                    LastName             = "Ivanov",
                    PhoneNumber          = "1234567890",
                },
                JobOfferDetails = new JobApplicationJobOfferDetailsViewModel
                {
                    Position = "CEO",
                },
                DocumentIds = new List <string> {
                    "First"
                },
            };
            var result = service.Apply(model, "someUrl");

            Assert.NotNull(result);
            Assert.NotEqual(0, context.JobApplicationDocuments.Count());
        }
Пример #6
0
        public async Task DeleteFailsWhenIdNotInDatabase()
        {
            AutoMapperInitializer.InitializeMapper();
            var context    = InMemoryDbContextInitializer.InitializeContext();
            var repository = new EfDeletableEntityRepository <Skill>(context);

            var service = new SkillsService(repository);
            var result  = await service.DeleteAsync(100);

            Assert.False(result);
        }
        public async Task IsOfferPostedByEmployerReturnsCorrectDataWhenTrue()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobOffers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobOffer>(context);
            var service    = this.GetMockedService(repository);
            var result     = service.IsOfferPostedByEmployer("1", "111");

            Assert.True(result);
        }
        public async Task GetDetailsReturnsCorrectInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobOffers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobOffer>(context);
            var service    = this.GetMockedService(repository);
            var result     = service.GetDetails <JobOfferDetailsViewModel>("1");

            Assert.NotNull(result);
        }
        public async Task GetNewOffersCountReturnsCorrectCount()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobOffers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobOffer>(context);
            var service    = this.GetMockedService(repository);
            var result     = service.GetNewOffersCount();

            Assert.Equal(10, result);
        }
Пример #10
0
        public async Task HasCandidateAppliedForOfferReturnsCorrectInfoWhenApplicationIsRetracted()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobApplications.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobApplication>(context);
            var service    = this.GetMockedService(repository);
            var result     = service.HasCandidateAppliedForOffer("Second", "3");

            Assert.False(result);
        }
        public async Task IsPositionDuplicateReturnsCorrectInformationWhenFalse()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobOffers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobOffer>(context);
            var service    = this.GetMockedService(repository);
            var result     = service.IsPositionDuplicate("222", "Not CFO");

            Assert.False(result);
        }
Пример #12
0
        IsUserRelatedToJobApplicationReturnsCorrectInformationWhenFalse()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobApplications.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobApplication>(context);
            var service    = this.GetMockedService(repository);
            var result     = service.IsUserRelatedToJobApplication("2", "UserId");

            Assert.False(result);
        }
Пример #13
0
        public async Task GetNewEmployersCountShouldReturnCorrectResult()
        {
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Employers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository       = new EfDeletableEntityRepository <Employer>(context);
            var employersService = this.GetMockedService(repository);

            var count = employersService.GetNewEmployersCount();

            Assert.Equal(2, count);
        }
Пример #14
0
        public async Task GetEmployerIdByUsernameReturnsCorrectResult()
        {
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Employers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository       = new EfDeletableEntityRepository <Employer>(context);
            var employersService = this.GetMockedService(repository);

            var employerId = employersService.GetEmployerIdByUsername("searchableId");

            Assert.Equal("CorrectResult", employerId);
        }
Пример #15
0
        public async Task GetAllReturnsCorrectNumberOfRecords()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Skills.AddRangeAsync(this.SeedData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <Skill>(context);

            var service = new SkillsService(repository);
            var result  = service.GetAll <EditViewModel>();

            Assert.Equal(2, result.Count());
        }
        public async Task DeleteAsyncReturnsFalseWhenRecordNotInDatabase()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobOffers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobOffer>(context);
            var service    = this.GetMockedService(repository);

            var result = await service.DeleteAsync("111");

            Assert.False(result);
        }
        public async Task DeleteAsyncCorrectlyMarksRecordAsDeleted()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobOffers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobOffer>(context);
            var service    = this.GetMockedService(repository);

            var result = await service.DeleteAsync("1");

            Assert.True(result);
        }
Пример #18
0
        public async Task GetJobOfferIdForApplicationReturnsCorrectId()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobApplications.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobApplication>(context);
            var service    = this.GetMockedService(repository);

            var result = service.GetJobOfferIdForApplication("4");

            Assert.Equal("112", result);
        }
Пример #19
0
        public async Task IsCandidateOwnerOfDocumentReturnsCorrectInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Documents.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository       = new EfDeletableEntityRepository <Document>(context);
            var documentsService = this.GetMockedService(repository, null, null);

            var result = documentsService.IsCandidateOwnerOfDocument("CandidateId", "11");

            Assert.True(result);
        }
Пример #20
0
        public async Task GetAllDocumentsForCandidateReturnsCorrectInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Documents.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository       = new EfDeletableEntityRepository <Document>(context);
            var documentsService = this.GetMockedService(repository, null, null);

            var result = documentsService.GetAllDocumentsForCandidate <DocumentsViewModel>("CandidateId");

            Assert.Equal(2, result.Count());
        }
Пример #21
0
        public async Task GetTopFiveEmployersReturnsCorrectInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Employers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository       = new EfDeletableEntityRepository <Employer>(context);
            var employersService = this.GetMockedService(repository, null);

            var result = employersService.GetTopFiveEmployers <IndexTopEmployersModel>();

            Assert.DoesNotContain("First", result.Select(r => r.Id).ToList());
        }
Пример #22
0
        public async Task GetEmployerNameByIdReturnsCorrectInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Employers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository       = new EfDeletableEntityRepository <Employer>(context);
            var employersService = this.GetMockedService(repository, null);

            var result = employersService.GetEmployerNameById("First");

            Assert.Equal("Recruit Me", result);
        }
Пример #23
0
        public async Task IfEmployerDoesNotExistUpdateProfileReturnsNull()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Employers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository       = new EfDeletableEntityRepository <Employer>(context);
            var employersService = this.GetMockedService(repository, null);

            var result = employersService.GetProfileDetails <ProfileViewModel>("IdNotInDatabase");

            Assert.Null(result);
        }
Пример #24
0
        public async Task GetDocumentNameByIdReturnsCorrectInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Documents.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository       = new EfDeletableEntityRepository <Document>(context);
            var documentsService = this.GetMockedService(repository, null, null);

            var result = documentsService.GetDocumentNameById("11");

            Assert.Equal("File1.doc", result);
        }
Пример #25
0
        public async Task GetCandidateApplicationsReturnsCorrectInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobApplications.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobApplication>(context);

            var service = this.GetMockedService(repository);

            var result = service.GetCandidateApplications <CandidateJobApplicationsViewModel>("Second");

            Assert.Equal(2, result.Count());
        }
Пример #26
0
        GetJobApplicationDetailsReturnsCorrectInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobApplications.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobApplication>(context);
            var service    = this.GetMockedService(repository);
            var result     = service.GetJobApplicationDetails <CandidateJobApplicationsViewModel>("1");

            Assert.NotNull(result);
            Assert.Equal("CEO", result.JobOfferPosition);
            Assert.Equal("First", result.ApplicationStatusName);
        }
Пример #27
0
        public async Task GetImageExtensionsReturnsCorrectNumberOfRecords()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.FileExtensions.AddRangeAsync(this.SeedData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <FileExtension>(context);

            var service = new FileExtensionsService(repository);

            var result = service.GetImageExtensions();

            Assert.Equal(2, result.Count());
        }
        public async Task GetProfileDetailsReturnsCorrectData()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.Candidates.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var candidatesRepository = new EfDeletableEntityRepository <Candidate>(context);
            var candidatesService    = this.GetMockedService(candidatesRepository, null, null, null);

            var result = candidatesService.GetProfileDetails <ProfileViewModel>("First");

            Assert.NotNull(result);
            Assert.Equal("Ivan Ivanov", result.Name);
        }
Пример #29
0
        public async Task ChangeJobApplicationStatusDoesNotUpdateStatusIfStatusDoesNotExist()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobApplications.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository         = new EfDeletableEntityRepository <JobApplication>(context);
            var statusesRepository = new EfDeletableEntityRepository <JobApplicationStatus>(context);
            var service            = this.GetMockedService(repository, null, null, statusesRepository, null);

            var result = await service.ChangeJobApplicationStatus("1", 2222, "someUrl");

            Assert.Equal(-1, result);
        }
        public async Task GetAllValidFilteredOffersAsyncReturnsAllOffersWhenFilterModelIsEmpty()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.JobOffers.AddRangeAsync(this.SeedTestData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <JobOffer>(context);
            var service    = this.GetMockedService(repository);

            var filterModel = new FilterModel();

            var result = await service.GetAllValidFilteredOffersAsync <IndexJobOffersModel>(filterModel);

            Assert.Equal(10, result.Count());
        }