public async void Update_ApplicationExists_UpdatesJobApplication()
        {
            // Arrange
            var jobApplication = new JobApplicationEntity
            {
                Id              = _jobApplicationEntities[0].Id,
                CompanyName     = "New company",
                ApplicationDate = new DateTime(2017, 12, 20),
                CurrentStatus   = Status.Offer
            };

            _jobApplicationDbContext.JobApplications.Add(_jobApplicationEntities[0]);
            _jobApplicationDbContext.SaveChanges();

            JobApplicationDbContext context = ContextFixture.GetContext(_guid);

            _jobApplicationRepository = new JobApplicationRepository(context);

            // Act
            await _jobApplicationRepository.Update(jobApplication).ConfigureAwait(false);

            // Assert
            JobApplicationEntity entity = ContextFixture.GetContext(_guid).JobApplications.FirstOrDefault(x => x.Id == jobApplication.Id);

            Assert.Equal(jobApplication, entity);
        }
        public async void Create_ApplicationExists_ThrowException()
        {
            // Arrange
            var jobApplication = new JobApplicationEntity
            {
                Id              = _jobApplicationEntities[0].Id,
                CompanyName     = "New company",
                ApplicationDate = new DateTime(2017, 12, 20),
                CurrentStatus   = Status.Offer
            };

            _jobApplicationDbContext.JobApplications.Add(_jobApplicationEntities[0]);
            _jobApplicationDbContext.SaveChanges();

            JobApplicationDbContext context = ContextFixture.GetContext(_guid);

            _jobApplicationRepository = new JobApplicationRepository(context);

            // Act
            Exception ex = await Record.ExceptionAsync(async() => await _jobApplicationRepository.Create(jobApplication).ConfigureAwait(false))
                           .ConfigureAwait(false);

            // Assert
            JobApplicationEntity entity = ContextFixture.GetContext(_guid).JobApplications.FirstOrDefault(x => x.Id == jobApplication.Id);

            Assert.Equal(entity, _jobApplicationEntities[0]);
            Assert.IsType <ArgumentException>(ex);
            Assert.NotNull(ex);
        }
 public JobApplicationRepositoryTest()
 {
     _guid = Guid.NewGuid();
     _jobApplicationDbContext  = ContextFixture.GetContext(_guid);
     _jobApplicationRepository = new JobApplicationRepository(_jobApplicationDbContext);
     _jobApplicationEntities   = new[]
     {
         new JobApplicationEntity
         {
             Id              = 1,
             CompanyName     = "Company 1",
             ApplicationDate = new DateTime(2017, 11, 13),
             CurrentStatus   = Status.Interview
         },
         new JobApplicationEntity
         {
             Id              = 2,
             CompanyName     = "Company 2",
             ApplicationDate = new DateTime(2017, 11, 14),
             CurrentStatus   = Status.Applied
         },
         new JobApplicationEntity
         {
             Id              = 3,
             CompanyName     = "Company 3",
             ApplicationDate = new DateTime(2017, 11, 14),
             CurrentStatus   = Status.Interview
         },
         new JobApplicationEntity
         {
             Id              = 4,
             CompanyName     = "Company 4",
             ApplicationDate = new DateTime(2017, 10, 9),
             CurrentStatus   = Status.Offer
         },
         new JobApplicationEntity
         {
             Id              = 5,
             CompanyName     = "Company 5",
             ApplicationDate = new DateTime(2017, 09, 18),
             CurrentStatus   = Status.Rejected
         }
     };
 }
Exemple #4
0
        public void GivenNewJobapplication_WhenSavingNewJobapplication_ThenJobapplicationIsSaved()
        {
            using (var context = new SwintakeContext(_options))
            {
                //Given
                var newJobApplication = new JobApplicationBuilder()
                                        .WithId(Guid.NewGuid())
                                        .WithCandidateId(Guid.NewGuid())
                                        .WithCampaignId(Guid.NewGuid())
                                        .WithStatus(StatusJobApplication.Active)
                                        .Build();

                _jobApplicationRepository = new JobApplicationRepository(context);

                //When
                _jobApplicationRepository.Save(newJobApplication);

                //Then
                Assert.Contains(newJobApplication, context.JobApplications);
            }
        }
Exemple #5
0
        public void GivenExistingJobApplication_WhenRejectingJobApplication_ThenJobApplicationIsRemoved()
        {
            using (var context = new SwintakeContext(_options))
            {
                //Given
                var newJobApplication = new JobApplicationBuilder()
                                        .WithId(Guid.NewGuid())
                                        .WithCandidateId(Guid.NewGuid())
                                        .WithCampaignId(Guid.NewGuid())
                                        .WithStatus(StatusJobApplication.Active)
                                        .Build();

                _jobApplicationRepository = new JobApplicationRepository(context);
                _jobApplicationRepository.Save(newJobApplication);

                //When
                newJobApplication.SetNewStatus(StatusJobApplication.Rejected);

                //then
                Assert.Equal(StatusJobApplication.Rejected, newJobApplication.Status);
            }
        }
Exemple #6
0
        public void GivenJobapplication_WhenUpdate_ThenUpdateJobApplicationInContext()
        {
            using (var context = new SwintakeContext(_options))
            {
                var newJobApplication = new JobApplicationBuilder()
                                        .WithId(Guid.NewGuid())
                                        .WithCandidateId(Guid.NewGuid())
                                        .WithCampaignId(Guid.NewGuid())
                                        .WithStatus(StatusJobApplication.Active)
                                        .Build();

                _jobApplicationRepository = new JobApplicationRepository(context);
                _jobApplicationRepository.Save(newJobApplication);

                newJobApplication.Status = StatusJobApplication.Hired;
                _jobApplicationRepository.Update(newJobApplication);

                var jobapplication =
                    context.JobApplications.SingleOrDefault(jobapp => jobapp.Id == newJobApplication.Id);

                Assert.Equal(StatusJobApplication.Hired, jobapplication.Status);
            }
        }
Exemple #7
0
 public JobApplicationService(MongoClient _db)
 {
     _jobApplicationRepo = new JobApplicationRepository(_db);
 }
Exemple #8
0
 public JobApplicationRepositoryTest()
 {
     client = new MongoClient(MONGODB_TEST_CONNECTION_STRING);
     jar    = new JobApplicationRepository(client);
 }
Exemple #9
0
 public JobApplicationService(JobApplicationRepository repository, FileRepository fileRepository, ILoggerManager loggerManager)
 {
     _repository     = repository;
     _fileRepository = fileRepository;
     _loggerManager  = loggerManager;
 }