コード例 #1
0
        public void ShouldGetNoCurrentSchoolYearWhenAmbiguous()
        {
            // Under normal circumstances, 1 or 0 rows in the edfi.SchoolYearType
            // table will be marked as current. However, we should not use a
            // strict SingleOrDefault behavior when fetching the current year.
            // If we did, users would experience an exception when we would
            // rather give them the opportunity to fix their year setting.
            // So, when the table is ambiguous, we expect null, the same
            // as when there are zero records marked as current.

            GetNewSchoolYear(2000);
            GetNewSchoolYear(1999);
            GetNewSchoolYear(2001);
            GetCurrentSchoolYear().ShouldBe(null);

            // Create an ambiguous, meaningless selection of multiple years.
            using (var connection = TestConnectionProvider.CreateNewConnection(InstanceName, ApiMode))
                connection.Execute(@"UPDATE edfi.SchoolYearType SET CurrentSchoolYear='true'");

            // Rather than throwing, the user should experience this as no valid selection.
            GetCurrentSchoolYear().ShouldBe(null);

            // Users can correct the problem by selecting a year.
            SetSchoolYear(2000);
            GetCurrentSchoolYear().ShouldBeSchoolYear(2000, isCurrent: true);
        }
 private void SetStudentLimitedEnglishProficiencyDescriptor(int studentUsi, int?limitedEnglishProficiencyDescriptorId)
 {
     using (var sqlConnection = TestConnectionProvider.CreateNewConnection(null))
     {
         sqlConnection.Execute(@"
             UPDATE edfi.StudentEducationOrganizationAssociation
             SET LimitedEnglishProficiencyDescriptorId = @LimitedEnglishProficiencyDescriptorId
             WHERE StudentUSI = @StudentUsi"
                               , new { StudentUsi = studentUsi, LimitedEnglishProficiencyDescriptorId = limitedEnglishProficiencyDescriptorId });
     }
 }
 private void SetStudentCharacteristicDescriptor(int studentUsi, int studentCharacteristicDescriptorId, int edOrgId)
 {
     using (var sqlConnection = TestConnectionProvider.CreateNewConnection(null))
     {
         sqlConnection.Execute(@"
         INSERT INTO [edfi].[StudentEducationOrganizationAssociationStudentCharacteristic]
         (
             [EducationOrganizationId],
             [StudentUSI],
             [StudentCharacteristicDescriptorId]
         )
          VALUES
         (
             @EducationOrganizationId,
             @StudentUsi,
             @StudentCharacteristicDescriptorId
         )"
                               , new { EducationOrganizationId = edOrgId, StudentUsi = studentUsi, StudentCharacteristicDescriptorId = studentCharacteristicDescriptorId });
     }
 }
 private static void SetStudentRiskStatus(int studentUsi, string riskStatus, int edOrgId)
 {
     using (var sqlConnection = TestConnectionProvider.CreateNewConnection(null))
     {
         sqlConnection.Execute(@"
             INSERT INTO [edfi].[StudentEducationOrganizationAssociationStudentIndicator]
            (
                 [EducationOrganizationId],
                 [StudentUSI],
                 [IndicatorName],
                 [Indicator]
             )
             VALUES
             (
                 @EducationOrganizationId,
                 @StudentUsi,
                 @RiskStatus,
                 @RiskStatus
             )"
                               , new { EducationOrganizationId = edOrgId, StudentUsi = studentUsi, RiskStatus = riskStatus });
     }
 }
        private void EnrollInFoodServiceProgram(int studentUsi, int schoolFoodServicesEligibilityDescriptorId, int edOrgId, int programTypeDescriptorId = 1, string programName = "Fake Program", DateTime?beginDate = null, DateTime?endDate = null)
        {
            var nonNullBeginDate = beginDate ?? DateTime.Now;

            EnrollStudentInProgram(studentUsi, edOrgId, programTypeDescriptorId, programName, nonNullBeginDate, endDate);

            using (var sqlConnection = TestConnectionProvider.CreateNewConnection(null))
            {
                sqlConnection.Execute(@"
                    INSERT INTO [edfi].[StudentSchoolFoodServiceProgramAssociation]
                    (
                        [BeginDate],
                        [EducationOrganizationId],
                        [ProgramEducationOrganizationId],
                        [ProgramName],
                        [ProgramTypeDescriptorId],
                        [StudentUSI]
                    )
                    VALUES
                    (
                        @BeginDate,
                        @EducationOrganizationId,
                        @EducationOrganizationId,
                        @ProgramName,
                        @ProgramTypeDescriptorId,
                        @StudentUsi
                    )
                    ",
                                      new
                {
                    BeginDate = nonNullBeginDate,
                    EducationOrganizationId        = edOrgId,
                    ProgramEducationOrganizationId = edOrgId,
                    ProgramName             = programName,
                    ProgramTypeDescriptorId = programTypeDescriptorId,
                    StudentUsi = studentUsi
                });

                sqlConnection.Execute(@"
                    INSERT INTO [edfi].[StudentSchoolFoodServiceProgramAssociationSchoolFoodServiceProgramService]
                    (
                        [BeginDate],
                        [EducationOrganizationId],
                        [ProgramEducationOrganizationId],
                        [ProgramName],
                        [ProgramTypeDescriptorId],
                        [SchoolFoodServiceProgramServiceDescriptorId],
                        [StudentUSI]
                    )
                     VALUES
                    (
                        @BeginDate,
                        @EducationOrganizationId,
                        @EducationOrganizationId,
                        @ProgramName,
                        @ProgramTypeDescriptorId,
                        @SchoolFoodServiceProgramServiceDescriptorId,
                        @StudentUsi
                    )",
                                      new
                {
                    BeginDate = nonNullBeginDate,
                    EducationOrganizationId        = edOrgId,
                    ProgramEducationOrganizationId = edOrgId,
                    ProgramName             = programName,
                    ProgramTypeDescriptorId = programTypeDescriptorId,
                    SchoolFoodServiceProgramServiceDescriptorId = schoolFoodServicesEligibilityDescriptorId,
                    StudentUsi = studentUsi
                });
            }
        }