public async Task DeleteJobSeeker_WithNonExistentUser_ReturnsFalse() { var testId = Guid.NewGuid().ToString(); var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var personalDataService = new PersonalDataService(new EfRepository <Company>(context), new EfRepository <ContactMessage>(context), new EfRepository <Job>(context), new EfRepository <JobSeeker>(context), new EfRepository <JobCandidate>(context), new EfRepository <User>(context), new EfRepository <Resume>(context)); var result = await personalDataService.DeleteJobSeeker(testId); Assert.False(result); }
public async Task DeleteJobSeeker_WithExistingJobSeeker_WorksCorrectly() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var testUsers = new List <User> { new User { UserName = "******", Email = "*****@*****.**", ContactMessages = new List <ContactMessage>() { new ContactMessage() { Subject = "SubjectTest", Message = "MessageTest" } } }, new User { UserName = "******", Email = "*****@*****.**", } }; var model = new JobSeeker() { FirstName = "FirstNameTest1", LastName = "LastNameTest1", User = testUsers[0], UserJobs = new List <JobCandidate>() { new JobCandidate() { Job = new Job() { Title = "Test Job Title1", Location = "Test Location1", Description = "Random description1", EndDate = DateTime.UtcNow.AddDays(1), Category = new Category() { CategoryType = "NewCategory1" }, JobType = new JobType() { Type = "NewType1" } } } }, Resume = new Resume() }; await context.AddAsync(model); context.SaveChanges(); var personalDataService = new PersonalDataService(new EfRepository <Company>(context), new EfRepository <ContactMessage>(context), new EfRepository <Job>(context), new EfRepository <JobSeeker>(context), new EfRepository <JobCandidate>(context), new EfRepository <User>(context), new EfRepository <Resume>(context)); var result = await personalDataService.DeleteJobSeeker(testUsers[0].Id); Assert.True(result); var contactMessagesCount = await context.ContactMessages.CountAsync(); Assert.Equal(0, contactMessagesCount); var jobsCandidateCount = await context.JobsCandidates.CountAsync(); Assert.Equal(0, jobsCandidateCount); var jobSeekersCount = await context.JobSeekers.CountAsync(); Assert.Equal(0, jobSeekersCount); var resumeCount = await context.Resumes.CountAsync(); Assert.Equal(0, resumeCount); var usersCount = await context.Users.CountAsync(); Assert.Equal(0, usersCount); }