コード例 #1
0
        public async Task TranscriptRequest_Bulk_Send_Success()
        {
            // Arrange
            List <SendTranscriptViewModel> input = new List <SendTranscriptViewModel>()
            {
                new SendTranscriptViewModel {
                    TranscriptRequestId = 65, StudentId = "12345", TranscriptId = 1, SchoolId = xello_test_account_school_id, ReceivingInstitutionCode = "45784", ReceivingInstitutionName = "NCAA"
                },
                new SendTranscriptViewModel {
                    TranscriptRequestId = 83, StudentId = "12345", TranscriptId = 1, SchoolId = xello_test_account_school_id, ReceivingInstitutionCode = "45785", ReceivingInstitutionName = "Xello College"
                },
                new SendTranscriptViewModel {
                    TranscriptRequestId = 94, StudentId = "12345", TranscriptId = 1, SchoolId = xello_test_account_school_id, ReceivingInstitutionCode = "45786", ReceivingInstitutionName = "Great College"
                }
            };
            SchoolSettingModel schoolSettings = new SchoolSettingModel
            {
                SchoolSettingId     = 1,
                SchoolId            = xello_test_account_school_id,
                IsTranscriptEnabled = true
            };

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));

            // Act
            await CreateService().BulkSendTranscriptRequestAsync(input, xello_test_account_school_id, 1);

            // Assert (ran the underlying API call) in loop
            _mockTranscriptProviderAPIService.Verify(m => m.SendTranscriptRequestAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), ""), Times.Exactly(3));

            // Assert (appended to transcript request history)
            _mockTranscriptRequestRepository.Verify(m => m.AppendHistoryAsync(It.IsAny <List <int> >(), TranscriptRequestStatus.Submitted, It.IsAny <int>()));
        }
コード例 #2
0
 private void LicenseCheck(SchoolSettingModel schoolSettings)
 {
     if (schoolSettings == null || !schoolSettings.IsTranscriptEnabled)
     {
         throw new UnlicensedSchoolException("A transcript provider action was attempted with a school that is not licensed with the transcript provider.", "SendTranscriptRequest", schoolSettings.SchoolId);
     }
 }
コード例 #3
0
        public async Task ImportTranscriptAsync(int schoolId, int educatorId, string fileType, Stream fileStream)
        {
            // Get School Settings
            SchoolSettingModel schoolSettings = await _schoolSettingRepository.GetBySchoolIdAsync(schoolId);

            // License check
            LicenseCheck(schoolSettings);

            // Send the transcript via API
            await _transcriptProviderAPIService.ImportTranscriptAsync(schoolSettings.TranscriptProviderId, schoolId, fileType, fileStream);
        }
コード例 #4
0
        public async Task DeleteTranscriptAsync(int schoolId, string studentId, int transcriptId)
        {
            // Get School Settings
            SchoolSettingModel schoolSettings = await _schoolSettingRepository.GetBySchoolIdAsync(schoolId);

            // License check
            LicenseCheck(schoolSettings);

            // Delete the transcript via API
            await _transcriptProviderAPIService.DeleteTranscriptAsync(schoolSettings.TranscriptProviderId, schoolId, studentId, transcriptId);
        }
コード例 #5
0
        public async Task SendTranscriptRequestAsync(int transcriptRequestId, string studentId, int transcriptId, int schoolId, string receivingInstitutionCode, string receivingInstitutionName, int modifiedById, string receivingInstitutionEmail = "")
        {
            // Get School Settings
            SchoolSettingModel schoolSettings = await _schoolSettingRepository.GetBySchoolIdAsync(schoolId);

            // License check
            LicenseCheck(schoolSettings);

            // Send the transcript request via API
            await _transcriptProviderAPIService.SendTranscriptRequestAsync(schoolSettings.TranscriptProviderId, transcriptRequestId, studentId, transcriptId, schoolId, receivingInstitutionCode, receivingInstitutionName, receivingInstitutionEmail);

            // Update the transcript request history
            await _transcriptRequestRepository.AppendHistoryAsync(transcriptRequestId, TranscriptRequestStatus.Submitted, modifiedById);
        }
コード例 #6
0
        public async Task CheckAccess_should_return_true()
        {
            // Arrange:
            var schoolSetting = new SchoolSettingModel()
            {
                SchoolSettingId = 1, SchoolId = 1234, TranscriptProviderId = "cr-1234", IsTranscriptEnabled = true
            };

            _mockSchoolSettingRepo.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).ReturnsAsync(schoolSetting);

            // Act:
            var result = await CreateService().CheckAccessAsync(1234, CountryType.US, new[] { 9, 10, 11, 12 });

            // Assert:
            Assert.IsTrue(result);
        }
コード例 #7
0
        public async Task EducatorHasAccessToTranscripts_should_return_false_if_region()
        {
            // Arrange:
            var schoolSetting = new SchoolSettingModel()
            {
                SchoolSettingId = 1, SchoolId = 1234, TranscriptProviderId = "cr-1234", IsTranscriptEnabled = true
            };

            _mockSchoolSettingRepo.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).ReturnsAsync(schoolSetting);

            // Act:
            var result = await CreateService().EducatorHasAccessToTranscriptsAsync(1234, InstitutionTypeEnum.Region, CountryType.US, new[] { 9, 10, 11, 12 });

            // Assert:
            Assert.IsFalse(result);
        }
コード例 #8
0
        public async Task TranscriptRequest_SendForInactiveSchool_ShouldThrowUnlicensedSchoolException()
        {
            // Arrange
            SchoolSettingModel schoolSettings = new SchoolSettingModel();

            schoolSettings.SchoolSettingId     = 1;
            schoolSettings.SchoolId            = 12345;
            schoolSettings.IsTranscriptEnabled = false;

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));
            ITranscriptProviderService tps = CreateService();

            // Act
            await tps.SendTranscriptRequestAsync(55, "12345", 1, 12345, "45784", "NCAA", 1, "");

            // Assert (ExpectedException) -> See the applied ExpectedException attribute to the test's method
        }
コード例 #9
0
        public async Task TranscriptRequest_DeleteForInactiveSchool_ShouldThrowUnlicensedSchoolException()
        {
            // Arrange
            SchoolSettingModel schoolSettings = new SchoolSettingModel();

            schoolSettings.SchoolSettingId     = 1;
            schoolSettings.SchoolId            = xello_test_account_school_id;
            schoolSettings.IsTranscriptEnabled = false;

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));

            ITranscriptProviderService tps = CreateService();

            // Act
            await tps.DeleteTranscriptAsync(xello_test_account_school_id, "Student1234", 55);

            // Assert (ExpectedException)  -> See the applied ExpectedException attribute to the test's method
        }
コード例 #10
0
        public async Task BulkSendTranscriptRequestAsync(IEnumerable <SendTranscriptViewModel> sendTranscriptInfos, int currentSchool, int modifiedById)
        {
            // Get School Settings
            SchoolSettingModel schoolSettings = await _schoolSettingRepository.GetBySchoolIdAsync(currentSchool);

            // License check
            LicenseCheck(schoolSettings);
            var successfullySentIdList = new List <int>();

            //@TODO: Find a way to use Task.WhenAll and handle failure
            foreach (SendTranscriptViewModel st in sendTranscriptInfos)
            {
                // Send the transcript request via API
                await _transcriptProviderAPIService.SendTranscriptRequestAsync(schoolSettings.TranscriptProviderId, st.TranscriptRequestId, st.StudentId, st.TranscriptId, st.SchoolId, st.ReceivingInstitutionCode, st.ReceivingInstitutionName);

                successfullySentIdList.Add(st.TranscriptRequestId);
            }
            // Update the transcript request history
            await _transcriptRequestRepository.AppendHistoryAsync(successfullySentIdList, TranscriptRequestStatus.Submitted, modifiedById);
        }
コード例 #11
0
        public async Task Transcript_ImportForUnlicensedSchool_ShouldThrowUnlicensedSchoolException()
        {
            // Arrange
            SchoolSettingModel schoolSettings = new SchoolSettingModel
            {
                SchoolSettingId     = 1,
                SchoolId            = xello_test_account_school_id,
                IsTranscriptEnabled = false
            };

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));

            ITranscriptProviderService tps = CreateService();
            MemoryStream fileStream        = new MemoryStream();

            // Act
            await tps.ImportTranscriptAsync(xello_test_account_school_id, 12, "pdf", fileStream);

            // Assert (ExpectedException)  -> See the applied ExpectedException attribute to the test's method
        }
コード例 #12
0
        public async Task Transcript_Delete_Success()
        {
            // Arrange
            SchoolSettingModel schoolSettings = new SchoolSettingModel
            {
                SchoolSettingId     = 1,
                SchoolId            = xello_test_account_school_id,
                IsTranscriptEnabled = true
            };

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));

            ITranscriptProviderService tps = CreateService();

            // Act
            await tps.DeleteTranscriptAsync(xello_test_account_school_id, "Student1234", 55);

            // Assert (ran the underlying API call)
            _mockTranscriptProviderAPIService.Verify(m => m.DeleteTranscriptAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>()), Times.Once());
        }
コード例 #13
0
        public async Task TranscriptRequest_Send_Success()
        {
            // Arrange
            SchoolSettingModel schoolSettings = new SchoolSettingModel();

            schoolSettings.SchoolSettingId     = 1;
            schoolSettings.SchoolId            = xello_test_account_school_id;
            schoolSettings.IsTranscriptEnabled = true;

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));
            ITranscriptProviderService tps = CreateService();

            // Act
            await tps.SendTranscriptRequestAsync(55, "12345", 1, xello_test_account_school_id, "45784", "NCAA", 1);

            // Assert (ran the underlying API call)
            _mockTranscriptProviderAPIService.Verify(m => m.SendTranscriptRequestAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), ""), Times.Once());

            // Assert (appended to transcript request history)
            _mockTranscriptRequestRepository.Verify(m => m.AppendHistoryAsync(It.IsAny <int>(), TranscriptRequestStatus.Submitted, It.IsAny <int>()));
        }
コード例 #14
0
        public async Task Transcript_Import_Success()
        {
            // Arrange
            SchoolSettingModel schoolSettings = new SchoolSettingModel
            {
                SchoolSettingId     = 1,
                SchoolId            = xello_test_account_school_id,
                IsTranscriptEnabled = true
            };

            _mockSchoolSettingRepository.Setup(x => x.GetBySchoolIdAsync(It.IsAny <int>())).Returns(Task.FromResult <SchoolSettingModel>(schoolSettings));

            ITranscriptProviderService tps = CreateService();
            MemoryStream fileStream        = new MemoryStream();

            // Act
            await tps.ImportTranscriptAsync(xello_test_account_school_id, 12, "pdf", fileStream);

            // Assert (ran the underlying API call)
            _mockTranscriptProviderAPIService.Verify(m => m.ImportTranscriptAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <MemoryStream>()), Times.Once());
        }
コード例 #15
0
        public async Task GetBySchoolIdAsync_should_return_setting_from_db()
        {
            // Arrange:
            // Clear the cache to make sure we are testing the sproc
            var cachekey = _cache.CreateKey("TranscriptsSchoolSettingGetBySchoolId", integrationTestSchoolId);
            await _cache.DeleteAsync(cachekey);

            var schoolSetting = new SchoolSettingModel {
                SchoolSettingId      = 2,
                SchoolId             = 250055,
                IsTranscriptEnabled  = true,
                TranscriptProviderId = "credentials-250055"
            };

            // Act:
            var result = await _schoolSettingRepository.GetBySchoolIdAsync(integrationTestSchoolId);

            // Assert:
            Assert.AreEqual(schoolSetting.SchoolSettingId, result.SchoolSettingId);
            Assert.AreEqual(schoolSetting.SchoolId, result.SchoolId);
            Assert.AreEqual(schoolSetting.IsTranscriptEnabled, result.IsTranscriptEnabled);
            Assert.AreEqual(schoolSetting.TranscriptProviderId, result.TranscriptProviderId);
        }