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
         }
     };
 }