コード例 #1
0
        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);
        }