Exemplo n.º 1
0
        public void Add_New_Applicant(
            string sureName, string middleName, string foreName, string gender, string dateOfBirth,
            string enrolmentStatus, string Class, string attendanceMode, string boarderStatus)
        {
            #region PRE-CONDITIONS:

            var          schoolIntakeId           = Guid.NewGuid();
            const string admissionTerm            = "Spring";
            const int    numberOfPlannedAdmission = 31;
            const int    capacity           = 10;
            var          admissionYear      = String.Format("{0}/{1}", (DateTime.Now.Year), (DateTime.Now.Year + 1));
            var          dateOfAdmission    = new DateTime(DateTime.Today.Year, 8, 8);
            var          admissionGroupName = Utilities.GenerateRandomString(10, "TC_AG01_Data");
            var          yearGroup          = Queries.GetFirstYearGroup();

            var dataPackage = this.BuildDataPackage();
            dataPackage.AddSchoolIntake(
                schoolIntakeId,
                admissionYear,
                admissionTerm,
                yearGroup,
                numberOfPlannedAdmission,
                admissionGroupName,
                dateOfAdmission,
                capacity);

            // Act
            using (new DataSetup(purgeBeforeInsert: false, purgeAfterTest: true, packages: dataPackage))
            {
                // Login as Admission
                SeleniumHelper.Login(SeleniumHelper.iSIMSUserType.AdmissionsOfficer);

                // Navigate to Application page
                AutomationSugar.NavigateMenu("Tasks", "Admissions", "Applications");

                Wait.WaitForAjaxReady();

                var applicantTriplet = new ApplicationTriplet();

                // Search to change to Admitted if existing Applicant
                applicantTriplet.SearchCriteria.SetStatus("Applied", true);
                applicantTriplet.SearchCriteria.SetStatus("Offered", true);
                applicantTriplet.SearchCriteria.SetStatus("Accepted", true);
                applicantTriplet.SearchCriteria.SearchByName = sureName;
                var searchResults = applicantTriplet.SearchCriteria.Search();
                var applicantTile = searchResults.SingleOrDefault(t => t.Code.Equals(sureName + ", " + foreName));
                applicantTriplet.ChangeToAdmit(applicantTile);

                #endregion

                #region STEPS:

                // Create new an Applicant
                applicantTriplet = new ApplicationTriplet();
                var addNewApplicationDialog = applicantTriplet.AddNewApplicationDialog();
                addNewApplicationDialog.ForeName    = foreName;
                addNewApplicationDialog.MiddleName  = middleName;
                addNewApplicationDialog.SureName    = sureName;
                addNewApplicationDialog.Gender      = gender;
                addNewApplicationDialog.DateofBirth = dateOfBirth;
                addNewApplicationDialog.Continue();

                // Navigate to Registration Details dialog
                var registrationDetailsDialog = new RegistrationDetailsDialog();
                registrationDetailsDialog.AdmissionGroup  = admissionGroupName;
                registrationDetailsDialog.EnrolmentStatus = enrolmentStatus;
                registrationDetailsDialog.Class           = Class;
                registrationDetailsDialog.AttendanceMode  = attendanceMode;
                registrationDetailsDialog.BoarderStatus   = boarderStatus;
                registrationDetailsDialog.AddRecord();

                var confirmRequiredDialog = new ConfirmRequiredDialog();
                confirmRequiredDialog.ClickOk();

                // Search Applicant that has just created
                //    applicantTriplet.SearchCriteria.SearchByName = sureName;
                //    searchResults = applicantTriplet.SearchCriteria.Search();
                //  applicantTile = searchResults.SingleOrDefault(t => t.Code.Equals(sureName + ", " + foreName));

                try
                {
                    // Verify that Applicant was created
                    //      Assert.IsNotNull(applicantTile, "Application record not created");

                    var applicationPage = new ApplicationPage();

                    // Verify that Applicant was created successfully
                    Assert.AreEqual(foreName, applicationPage.LegalForeName, "Legal ForName is not equal");
                    Assert.AreEqual(sureName, applicationPage.LegalSureName, "Legal SurName is not equal");
                    Assert.AreEqual(gender, applicationPage.Gender, "Gender is not equal");
                    Assert.AreEqual(dateOfBirth, applicationPage.DateOfBirth, "Date of Birth is not equal");
                    Assert.AreEqual(dateOfBirth.GetMonthsAndYears(), applicationPage.Age, "Ages is not equal");
                    Assert.AreEqual("Applied", applicationPage.ApplicationStatus, "Application Status is not equal");
                    Assert.AreEqual(admissionGroupName, applicationPage.AdmissionGroup, "Admission Group is not equal");
                    Assert.AreEqual("", applicationPage.AdmissionNumber, "Admission Number is not equal");
                    Assert.AreEqual(true, applicationPage.VerifyDisable(), "Age and Age On Entry are not disabled");
                }
                finally
                {
                    // Tear down linked records before clean up
                    var learnerId     = Queries.GetLearnerId(sureName, foreName, dateOfBirth);
                    var applicationId = Queries.GetApplicationId(learnerId);
                    PurgeLinkedData.DeleteApplicationStatusLog(applicationId);
                    PurgeLinkedData.DeleteApplication(applicationId);
                    PurgeLinkedData.DeleteLearnerEnrolmentStatusForPupil(learnerId);
                    PurgeLinkedData.DeleteLearnerEnrolmentForPupil(learnerId);
                    PurgeLinkedData.DeleteNcYearMembershipForPupil(learnerId);
                    PurgeLinkedData.DeleteYearGroupMembershipForPupil(learnerId);
                    PurgeLinkedData.DeleteAttendanceModelForLearner(learnerId);
                    PurgeLinkedData.DeleteBorderStatusForLearner(learnerId);
                    PurgeLinkedData.DeletePrimaryClassMembershipForLearner(learnerId);
                    PurgeLinkedData.DeletePupil(foreName, sureName);
                }
            }
            #endregion
        }