private void SetUp()
 {
     var sessionFilter = Substitute.For<ISessionFilter>();
     sessionFilter.FindSession(Arg.Any<DateTime>()).Returns(new SessionBuilder().WithSchoolYear(SchoolYearTypeEnum.Year2014).Build());
     _mapper = new StudentAttendancePercentageMapper(sessionFilter);
     _profileModel = new ProfileModel();
 }
        public void ShouldNotMapStudentProgramStatusIfItDoesNotExist()
        {
            SetupWithDownloaderReturning("");

            var student = new StudentBuilder().WithParent().Build();
            student.StudentProgramStatus = null;
            var profileModel = new ProfileModel();

            _mapper.Map(student, profileModel);

            profileModel.ProgramStatus.ShouldBe(null);
        }
        public void ShouldMapStudentToProfileModelWithDifferentParentAddress()
        {
            SetupWithDownloaderReturning("");

            var parent = new ParentBuilder().WithAddress().WithPhoneNumber().Build();
            var student = new StudentBuilder().WithParent(parent, false).Build();
            var profileModel = new ProfileModel();

            _mapper.Map(student, profileModel);

            NativeStudentPropertiesShouldBeMapped(student, profileModel);
            NativeParentPropertiesShouldBeMapped(parent, profileModel.EditProfileParentModel);
            ParentAddressShouldBeMapped(parent, profileModel);
            StudentParentAssociationShouldBeMapped(student, profileModel);
        }
        public void ShouldMapStudentToProfileModel()
        {
            SetupWithDownloaderReturning("");

            var student = new StudentBuilder().WithParent().WithStudentProgramStatus().WithAttendanceFlags(1).Build();

            var parent = student.StudentParentAssociations.First().Parent;
            var profileModel = new ProfileModel();

            _mapper.Map(student, profileModel);

            NativeStudentPropertiesShouldBeMapped(student, profileModel);
            NativeParentPropertiesShouldBeMapped(parent, profileModel.EditProfileParentModel);
            AddressShouldBeMapped(student.StudentAddresses.First(), profileModel);
            StudentParentAssociationShouldBeMapped(student, profileModel);
            profileModel.ProgramStatus.ShouldNotBe(null);
            _studentAttendancePercentageMapperMock.Received().Map(Arg.Any<IList<StudentSectionAttendanceEvent>>(), Arg.Any<ProfileModel>());
            profileModel.FlagCount.ShouldBe(student.AttendanceFlags.First().FlagCount);
        }
        public void ShouldMapStudentToProfileModelWithMultipleParents()
        {
            SetupWithDownloaderReturning("");

            var student = new StudentBuilder().WithParent().WithParent().Build();
            var firstParent = student.StudentParentAssociations.First().Parent;
            var secondParent = student.StudentParentAssociations.ElementAt(1).Parent;
            var profileModel = new ProfileModel();

            _mapper.Map(student, profileModel);

            NativeStudentPropertiesShouldBeMapped(student, profileModel);
            NativeParentPropertiesShouldBeMapped(firstParent, profileModel.EditProfileParentModel);
            NativeParentPropertiesShouldBeMapped(secondParent, profileModel.SecondEditProfileParentModel);
            StudentParentAssociationShouldBeMapped(student, profileModel);
        }
        private static void ParentAddressShouldBeMapped(Parent parent, ProfileModel profileModel)
        {
            var profileParentAddressModel = profileModel.EditProfileParentModel.EditableParentAddressModel;
            var parentHomeAddress = parent.ParentAddresses.First();

            profileParentAddressModel.Address.ShouldBe(parentHomeAddress.StreetNumberName);
            profileParentAddressModel.Address2.ShouldBe(parentHomeAddress.ApartmentRoomSuiteNumber);
            profileParentAddressModel.City.ShouldBe(parentHomeAddress.City);
            profileParentAddressModel.StateForDisplay.ShouldBe(
                ((StateAbbreviationTypeEnum)parentHomeAddress.StateAbbreviationTypeId).Humanize());
            profileParentAddressModel.PostalCode.ShouldBe(parentHomeAddress.PostalCode);
        }
        private static void AddressShouldBeMapped(StudentAddress address, ProfileModel profileModel)
        {
            var addressModel = profileModel.HomeAddress;

            addressModel.StudentUsi.ShouldBe(address.StudentUSI);
            addressModel.Address.ShouldBe(address.StreetNumberName);
            addressModel.Address2.ShouldBe(address.ApartmentRoomSuiteNumber);
            addressModel.City.ShouldBe(address.City);
            addressModel.State.ShouldBe((StateAbbreviationTypeEnum)address.StateAbbreviationTypeId);
            addressModel.PostalCode.ShouldBe(address.PostalCode);
        }
        private static void StudentParentAssociationShouldBeMapped(Web.Data.Entities.Student student, ProfileModel profileModel)
        {
            var profileParentModel = profileModel.EditProfileParentModel;
            var studentParentAssociation = student.StudentParentAssociations.First();
            profileParentModel.Relationship.ShouldBe(
                ((RelationTypeEnum)studentParentAssociation.RelationTypeId));

            profileParentModel.SameAddressAsStudent.ShouldBe((bool)studentParentAssociation.LivesWith);
        }
        private static void NativeStudentPropertiesShouldBeMapped(Web.Data.Entities.Student student, ProfileModel profileModel)
        {
            profileModel.StudentUsi.ShouldBe(student.StudentUSI);
            profileModel.StudentName.FirstName.ShouldBe(student.FirstName);
            profileModel.StudentName.LastName.ShouldBe(student.LastSurname);
            profileModel.BiographicalInfo.BirthDate.ShouldBe(student.BirthDate.ToShortDateString());

            var studentRace = student.StudentRaces.First();
            profileModel.BiographicalInfo.Race.ShouldBe((RaceTypeEnum)studentRace.RaceTypeId);
            profileModel.BiographicalInfo.RaceForDisplay.ShouldBe(((RaceTypeEnum)studentRace.RaceTypeId).Humanize());
            profileModel.BiographicalInfo.HispanicLatinoEthnicity.ShouldBe(student.HispanicLatinoEthnicity);
            profileModel.BiographicalInfo.Sex.ShouldBe((SexTypeEnum)student.SexTypeId);

            var studentProfileHomeLanguage = profileModel.BiographicalInfo.HomeLanguage;
            studentProfileHomeLanguage.ShouldBe((LanguageDescriptorEnum)student.StudentLanguages.First().LanguageDescriptorId);
        }
Ejemplo n.º 10
0
 private void StudentsBiographicalInformationIsEdited()
 {
     _newBiographicalInformation = new StudentBiographicalInformationModelBuilder().Build();
     var profileModel = new ProfileModel {BiographicalInfo = _newBiographicalInformation};
     _profilePage.EditBiographicalInfo(profileModel);
 }
Ejemplo n.º 11
0
        public override void Map(IList <Data.Entities.StudentSectionAttendanceEvent> source, ProfileModel target)
        {
            var schoolYear = _sessionFilter.FindSession(DateTime.Now.Date).SchoolYear;
            var attendanceForCurrentSchoolYear = source.Where(ssae => ssae.SchoolYear == schoolYear).ToList();

            var presents = attendanceForCurrentSchoolYear.Count(ae =>
                                                                ae.AttendanceEventCategoryDescriptorId == (int)AttendanceEventCategoryDescriptorEnum.InAttendance ||
                                                                ae.AttendanceEventCategoryDescriptorId == (int)AttendanceEventCategoryDescriptorEnum.Earlydeparture ||
                                                                ae.AttendanceEventCategoryDescriptorId == (int)AttendanceEventCategoryDescriptorEnum.ExcusedAbsence);

            target.AttendancePercentage = CalculateAttedancePercentage(presents, attendanceForCurrentSchoolYear);
        }