public void GivenEmailAddress_WhenFindByEmail_ThenReturnUser() { //given var options = new DbContextOptionsBuilder <SwintakeContext>() .UseInMemoryDatabase("swintake" + Guid.NewGuid().ToString("n")) .Options; using (var context = new SwintakeContext(options)) { var user = new UserBuilder() .WithEmail("*****@*****.**") .WithFirstName("User") .WithUserSecurity(new UserSecurity("WO8nNwTcrxigARQfBn4nYRh8X16ExDQJ8jNuECJT8fE=", "F1e3n6zNR75LhUd5K73T/g==")) .Build(); context.Users.Add(user); context.SaveChanges(); IUserRepository userRepository = new UserRepository(context); //when var foundUser = userRepository.FindByEmail("*****@*****.**"); //then Assert.Equal(user.Id, foundUser.Id); Assert.Equal(user.Email, foundUser.Email); Assert.Equal(user.FirstName, foundUser.FirstName); Assert.Equal(user.UserSecurity.AppliedSalt, foundUser.UserSecurity.AppliedSalt); Assert.Equal(user.UserSecurity.PasswordHashedAndSalted, foundUser.UserSecurity.PasswordHashedAndSalted); } }
public void GivenExistingCandidates_WhenGetAll_ThenReturnAllCandidates() { using (var context = new SwintakeContext(_options)) { var guidId = Guid.NewGuid(); var janneke = new CandidateBuilder() .WithId(guidId) .WithFirstName("Janneke") .WithLastName("Janssens") .WithEmail("*****@*****.**") .WithPhoneNumber("0470000000") .WithGitHubUsername("janneke") .WithLinkedIn("janneke") .Build(); IRepository <Candidate> candidateRepository = new CandidateRepository(context); //when candidateRepository.Save(janneke); IList <Candidate> searchCandidate = candidateRepository.GetAll(); //then Assert.Equal(1, searchCandidate.Count); } }
public void GivenANewCampaign_WhenSaveNewCampaign_ThenNewCampaignIsSaved() { //given var options = new DbContextOptionsBuilder <SwintakeContext>() .UseInMemoryDatabase("swintake" + Guid.NewGuid().ToString("n")) .Options; using (var context = new SwintakeContext(options)) { var testCampaign = new CampaignBuilder() .WithId(Guid.NewGuid()) .WithName("testName") .WithClient("testClient") .WithStatus(CampaignStatus.Active) .WithStartDate(DateTime.Today.AddDays(5)) .WithClassStartDate(DateTime.Today.AddDays(5)) .WithComment("testComment") .Build(); IRepository <Campaign> campaignRepository = new CampaignRepository(context); //when campaignRepository.Save(testCampaign); //then var foundCampaign = context.Campaigns.SingleOrDefault(camp => camp.Id == testCampaign.Id); Assert.Equal(testCampaign.Name, foundCampaign.Name); } }
public void GivenNonExistingCandidateId_WhenSearchId_ThenReturnNull() { using (var context = new SwintakeContext(_options)) { IRepository <Candidate> candidateRepository = new CandidateRepository(context); Candidate searchCandidate = candidateRepository.Get(Guid.NewGuid()); //then Assert.Null(searchCandidate); } }
public void GivenUnKnownEmailAddress_WhenFindByEmail_ThenReturnNull() { //given var options = new DbContextOptionsBuilder <SwintakeContext>() .UseInMemoryDatabase("swintake" + Guid.NewGuid().ToString("n")) .Options; using (var context = new SwintakeContext(options)) { IUserRepository userRepository = new UserRepository(context); //when var foundUser = userRepository.FindByEmail("*****@*****.**"); //then Assert.Null(foundUser); } }
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); } }
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); } }
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); } }
public void GivenANewCandidate_WhenSaveNewCandidate_ThenNewCandidateIsSaved() { using (var context = new SwintakeContext(_options)) { var janneke = new CandidateBuilder() .WithId(Guid.NewGuid()) .WithFirstName("Janneke") .WithLastName("Janssens") .WithEmail("*****@*****.**") .WithPhoneNumber("0470000000") .WithGitHubUsername("janneke") .WithLinkedIn("janneke") .Build(); IRepository <Candidate> candidateRepository = new CandidateRepository(context); //when candidateRepository.Save(janneke); //then var foundCandidate = context.Candidates.SingleOrDefault(cand => cand.Id == janneke.Id); Assert.Equal(janneke.FirstName, foundCandidate.FirstName); } }
public CampaignRepository(SwintakeContext context) { _context = context; }
public JobApplicationRepository(SwintakeContext context) { _context = context; }
public CandidateRepository(SwintakeContext context) { _context = context; }
public UserRepository(SwintakeContext dbContext) { _dbContext = dbContext; }