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 static JobApplicationDbContext GetContext(Guid id) { DbContextOptions <JobApplicationDbContext> options = new DbContextOptionsBuilder <JobApplicationDbContext>() .UseInMemoryDatabase(id.ToString()) .UseLoggerFactory(MyLoggerFactory) .EnableSensitiveDataLogging() .Options; var context = new JobApplicationDbContext(options); context.SaveChanges(); return(context); }
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 } }; }
/// <summary> /// This is the constructor of the ProjectService class /// </summary> /// <param name="context">Data base context</param> /// <param name="userService">The service that is responsible for the user</param> /// <param name="cvService">The service that is responsible for the CVs</param> public ProjectService(JobApplicationDbContext context, IUserService userService, ICvService cvService) { this.context = context; this.userService = userService; this.cvService = cvService; }
/// <summary> /// This is the constructor of the UserController class /// </summary> /// <param name="service">The User service that this controller will use</param> /// <param name="context">Data base context</param> public UserController(IUserService service, JobApplicationDbContext context) { this.service = service; this.context = context; }
public JobApplicationRepository(JobApplicationDbContext context) { _context = context; }
/// <summary> /// This is the constructor of the JobService class /// </summary> /// <param name="context">Data base context</param> /// <param name="userService">The service that is responsible for the user</param> public JobService(JobApplicationDbContext context, IUserService userService) { this.context = context; this.userService = userService; }
/// <summary> /// This is the constructor of the UserService class /// </summary> /// <param name="context">Data base context</param> public UserService(JobApplicationDbContext context) { this.context = context; }
/// <summary> /// This is the constructor of the JobsController class. /// </summary> /// <param name="UserService">The service, responsible for the User</param> /// <param name="JobsService">The service, responsible for the Jobs</param> /// <param name="context">Data base context</param> public JobsController(IUserService UserService, IJobService JobsService, JobApplicationDbContext context) { this.JobsService = JobsService; this.UserService = UserService; this.context = context; }
/// <summary> /// This is the constructor of the CvsController class. /// </summary> /// <param name="UserService">The service, responsible for the User</param> /// <param name="CVService">The service, responsible for the CV</param> /// <param name="context">Data base context</param> public CvsController(IUserService UserService, ICvService CVService, JobApplicationDbContext context) { this.UserService = UserService; this.CVService = CVService; this.context = context; }