public async Task CreateInvalidApplicant_InvalidAddress() { IApplicantDomainService service = GetService <IApplicantDomainService>(); var applicant = new Applicant { Name = "Ali_1", FamilyName = "Hosseini", Address = "Address", Age = 35, CountryOfOrigin = "Aruba", EMailAddress = "*****@*****.**" }; await Assert.ThrowsAsync <ArgumentException>(async() => await service.CreateAsync(applicant)); }
public async Task CreateValidApplicant() { IApplicantDomainService service = GetService <IApplicantDomainService>(); var applicant = new Applicant { Name = "Ali_1", FamilyName = "Hosseini", Address = "Address test", Age = 35, CountryOfOrigin = "Aruba", EMailAddress = "*****@*****.**", Hired = true }; var result = await service.CreateAsync(applicant); Assert.NotNull(result); Assert.NotEqual(0, result.ID); }
public async Task UpdateApplicant() { IApplicantDomainService service = GetService <IApplicantDomainService>(); var applicant = new Applicant { Name = "Ali_1", FamilyName = "Hosseini", Address = "Address test", Age = 35, CountryOfOrigin = "Aruba", EMailAddress = "*****@*****.**" }; await service.CreateAsync(applicant); var result = await service.GetAsync(applicant.ID); result.Name = "Ali_2"; await service.UpdateAsync(result); var updatedResult = await service.GetAsync(applicant.ID); Assert.NotNull(updatedResult); Assert.Equal("Ali_2", result.Name); }
public async Task GetApplicant_All() { using AppDbContext context = new AppDbContext(GetDbContextOptions()); context.Applicants.RemoveRange(context.Applicants); context.SaveChanges(); IApplicantDomainService service = GetService <IApplicantDomainService>(); var applicant = new Applicant { Name = "Ali_1", FamilyName = "Hosseini", Address = "Address test", Age = 35, CountryOfOrigin = "Aruba", EMailAddress = "*****@*****.**" }; var result1 = await service.CreateAsync(applicant); var applicant2 = new Applicant { Name = "Ali_1", FamilyName = "Hosseini", Address = "Address test", Age = 35, CountryOfOrigin = "Aruba", EMailAddress = "*****@*****.**" }; var result2 = await service.CreateAsync(applicant2); var applicants = service.GetAll().Where(x => x.ID == result1.ID || x.ID == result2.ID).ToList(); Assert.Equal(2, applicants.Count); }
public async Task DeleteApplicant() { IApplicantDomainService service = GetService <IApplicantDomainService>(); var applicant = new Applicant { Name = "Ali_1", FamilyName = "Hosseini", Address = "Address test", Age = 35, CountryOfOrigin = "Aruba", EMailAddress = "*****@*****.**" }; await service.CreateAsync(applicant); //Check Existence var result = await service.GetAsync(applicant.ID); Assert.NotNull(result); //Delete var updateState = await service.DeleteAsync(applicant.ID); Assert.True(updateState); //Check var deletedResult = await service.GetAsync(applicant.ID); Assert.Null(deletedResult); }
public ApplicantsController(IApplicantDomainService applicantDomainService, ILogger <ApplicantsController> logger) { _service = applicantDomainService; _logger = logger; }