public async Task SetStatusInterview_WithProperStatus_ShouldSetCorrectly() { //Arrange var applicantId = 1; var applicantFirstName = "New applicant firstName"; var applicantLastName = "New applicant lastName"; var testId = 1; var testDescription = "Description"; var testUrl = "https://www.mysite.bg/"; var ResultUrl = "https://www.resultMyTest.bg/"; var applicantModel = new CreateApplicantBindingModel() { Id = applicantId, FirstName = applicantFirstName, LastName = applicantLastName, }; await this.applicants.Create(applicantModel); var testModel = new InterviewerTestBindingModel() { Id = testId, Description = testDescription, Url = testUrl }; await this.tests.Create(testModel); var interviewModel = new CreateOnlineInterviewBindingModel() { Id = 1, ApplicantId = applicantModel.Id, TestId = testModel.Id }; await this.interviews.CreateOnline(interviewModel); var setResultModel = new AdminSetApplicantTestResult() { ApplicantId = applicantModel.Id, InterviewId = interviewModel.Id, ResultUrl = ResultUrl }; //Act await this.interviews.SetTestResult(setResultModel); //Assert var interview = this.dbContext.Interviews.First(); Assert.AreEqual(ResultUrl, interview.Result.ResultUrl); }
public async Task <IActionResult> SetTestResult(AdminSetApplicantTestResult model) { if (!ModelState.IsValid) { return(NotFound()); } await this.interviews.SetTestResult(model); return(RedirectToAction(nameof(Index))); }
public async Task SetTestResult_WithNullResult_ShouldThrowException() { //Arrange AdminSetApplicantTestResult testResultModel = null; //Act Func <Task> setTestResult = () => this.interviews.SetTestResult(testResultModel); //Assert await Assert.ThrowsExceptionAsync <NullReferenceException>(setTestResult); }
public async Task SetTestResult(AdminSetApplicantTestResult model) { var interview = await this.DbContext.Interviews.FindAsync(model.InterviewId); interview.Result = new Result() { InterviewId = interview.Id }; if (interview.ApplicantId != model.ApplicantId) { throw new InvalidOperationException("Invalid Identity details."); } interview.Result.ResultUrl = model.ResultUrl; await this.DbContext.SaveChangesAsync(); }