public async Task TranscriptCRUD_should_work_as_expected() { // Arrange: var receivedDateUtc = DateTime.UtcNow; var studentNumber = "AP-API-IT-2"; var studentName = "IntegrationTests-2, ApplicationPlanner.API"; var dob = "2000/01/01"; var transcript = new TranscriptModel { TranscriptId = 1000000, SchoolId = integrationTestSchoolId, StudentNumber = studentNumber, StudentName = studentName, DateOfBirth = dob, EmailAddress = "*****@*****.**", ReceivedDateUtc = receivedDateUtc, PortfolioId = 0, // unmatched this should be 0 LinkApprovedDateUTC = null, // unmatched this should be null EducatorId = 0, IsAutoLink = false, // unmatched this should be false IsAvailable = true, IsArchived = false }; // Reset await _sql.ExecuteAsync("DELETE FROM ApplicationPlanner.Transcript WHERE StudentNumber = @studentNumber", new { studentNumber }); await _sql.ExecuteAsync("DELETE FROM ApplicationPlanner.TranscriptLog WHERE StudentNumber = @studentNumber", new { studentNumber }); // Import a transcript and do not automatch it to the integration test student await _qaRepository.ImportTranscriptAsync(0, integrationTestSchoolId, studentNumber, studentName, dob, "*****@*****.**"); var justAddedTranscript = (await _transcriptRepository.GetTranscriptUnmatchedBySchoolIdAsync(integrationTestSchoolId)).SingleOrDefault(t => t.StudentNumber == studentNumber); // Act: // Delete and check if deleted + Get await _transcriptRepository.DeleteByIdAsync(justAddedTranscript.TranscriptId); var result = await _transcriptRepository.GetByIdAsync(justAddedTranscript.TranscriptId); Assert.IsTrue(result.IsAvailable == false); // Undo Delete and check if added back + Get await _transcriptRepository.DeleteUndoByIdAsync(justAddedTranscript.TranscriptId); result = await _transcriptRepository.GetByIdAsync(justAddedTranscript.TranscriptId); Assert.IsTrue(result.IsAvailable == true); Assert.AreEqual(justAddedTranscript.TranscriptId, result.TranscriptId); Assert.AreEqual(transcript.SchoolId, result.SchoolId); Assert.AreEqual(transcript.StudentNumber, result.StudentNumber); Assert.AreEqual(transcript.StudentName, result.StudentName); Assert.AreEqual(transcript.DateOfBirth, result.DateOfBirth); Assert.AreEqual(transcript.EmailAddress, result.EmailAddress); Assert.IsTrue(transcript.ReceivedDateUtc != null); Assert.AreEqual(transcript.PortfolioId, result.PortfolioId); Assert.AreEqual(transcript.LinkApprovedDateUTC, result.LinkApprovedDateUTC); Assert.AreEqual(transcript.EducatorId, result.EducatorId); Assert.AreEqual(transcript.IsAutoLink, result.IsAutoLink); Assert.AreEqual(transcript.IsArchived, result.IsArchived); }
public TranscriptModelTests() { _sut = new TranscriptModel( new YouTube( new HttpClient(), NullLogger <YouTube> .Instance ), NullLogger <TranscriptModel> .Instance); }
public static int CreateTranscript(int transcriptId, DateTime transcriptDate, bool transcriptStatus) { TranscriptModel data = new TranscriptModel { TranscriptId = transcriptId, TranscriptDate = transcriptDate, TranscriptStatus = transcriptStatus }; string sql = @"insert into dbo.Transcript (TranscriptId, TranscriptDate, TranscriptStatus) values (@TranscriptId, @TranscriptDate, @TranscriptStatus);"; return(SqlDataAccess.SaveData(sql, data)); }
public async Task <TranscriptModel> GetTranscriptResponseModelAsync(TranscriptModel transcript, int schoolId) { if (transcript != null) { var timeZoneId = await _timeZoneRepository.GeTimeZoneIdBySchoolIdAsync(schoolId); var timeZoneDetail = await _timeZoneRepository.GeTimeZoneDetailByIdAsync(timeZoneId); transcript.DateOfBirth = (DateTime.TryParse(transcript.DateOfBirth, out DateTime dateValue)) ? transcript.DateOfBirth : null; transcript.ReceivedDateUtc = DateTimeHelper.GetLocalTime(transcript.ReceivedDateUtc, timeZoneDetail); transcript.LinkApprovedDateUTC = transcript.LinkApprovedDateUTC == null ? transcript.LinkApprovedDateUTC : DateTimeHelper.GetLocalTime(transcript.LinkApprovedDateUTC ?? default(DateTime), timeZoneDetail); } return(transcript); }
public async Task Get_should_return_ok_with_correct_result() { // Arrange: var transcriptId = 1000000; var _mockTranscript = new TranscriptModel { TranscriptId = transcriptId }; _mockTranscriptRepository.Setup(tr => tr.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(_mockTranscript); _mockTranscriptService.Setup(ts => ts.GetTranscriptResponseModelAsync(It.IsAny <TranscriptModel>(), It.IsAny <int>())).ReturnsAsync(_mockTranscript); var sut = CreateController(); // Act var actionResult = await sut.Get(transcriptId); //Assert var contentResult = new OkObjectResult(actionResult); Assert.AreEqual(StatusCodes.Status200OK, contentResult.StatusCode); var response = Result <TranscriptModel>(actionResult); Assert.IsNotNull(response); Assert.AreEqual(transcriptId, response.TranscriptId); }