public void testParseGraduationDate()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Actual'>2005</GradYear>"
                          + "</StudentPersonal>";

            StudentPersonal sp = (StudentPersonal) parseSIF15r1XML( sXML );
            sp = (StudentPersonal) AdkObjectParseHelper.WriteParseAndReturn( sp, SifVersion.SIF11 );
            Assertion.AssertNotNull( sp );
            PartialDateType gd = sp.GraduationDate;
            Assertion.AssertNotNull( "Actual Grad Year", gd );
            Assertion.AssertEquals( "Actual Grad Year", 2005, (int) gd.Year );

            Adk.SifVersion = SifVersion.SIF15r1;
            sp = new StudentPersonal();
            sp.SetElementOrAttribute( "GradYear[@Type='Actual']", "2054" );
            gd = sp.GraduationDate;
            Assertion.AssertNotNull( "Actual Grad Year", gd );
            Assertion.AssertNotNull( "GraduationDate/getYear()", gd.Year );
            Assertion.AssertEquals( "Actual Grad Year", 2054, gd.Year.Value );

            Element gradValue = sp.GetElementOrAttribute( "GradYear[@Type='Actual']" );
            Assertion.AssertNotNull( "Actual Grad Year", gradValue );
            PartialDateType pdt = (PartialDateType) gradValue;
            Assertion.AssertEquals( "Actual Grad Year", 2054, pdt.Year.Value );
        }
        public void TestADKFunctionInbound()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                + "       <field name='FIRSTNAME'>//FirstName</field>"
                + "       <field name='LASTNAME'>//LastName</field>"
                + "       <field name='FULLNAME'>adk:toProperCase( concat( $FIRSTNAME, ' ', $LASTNAME ) )</field>"
                + "</object></mappings></agent>";

            StudentPersonal sp = new StudentPersonal();
            sp.SetElementOrAttribute( "Name/FirstName", "ahmad" );
            sp.SetElementOrAttribute( "Name/LastName", "O'TOOLE" );

            IDictionary map = doInboundMapping( customMappings, sp );

            Assertion.AssertEquals( "First Name", "ahmad", map["FIRSTNAME"] );
            Assertion.AssertEquals( "Last Name", "O'TOOLE", map["LASTNAME"] );
            Assertion.AssertEquals( "Full Name", "Ahmad O'Toole", map["FULLNAME"] );
        }
        public void CreateElementOrAttribute()
        {
            String firstName = "Rosemary";
             String middleName = null;
             String lastName = "Evans";
             StudentPersonal retval = new StudentPersonal();

             retval.SetElementOrAttribute("Name[@Type='04']/FirstName", firstName);
             retval.SetElementOrAttribute("Name[@Type='04']/MiddleName", middleName);
             retval.SetElementOrAttribute("Name[@Type='04']/LastName", lastName);

             Name name = retval.Name;
             Assert.AreEqual(firstName, name.FirstName, "First Name");
             Assert.AreEqual(lastName, name.LastName, "Last Name");
             Assert.IsNull(name.MiddleName, "Middle Name");

             // echo to the console so we can see what's going on
             SifWriter writer = new SifWriter(Console.Out);
             writer.Write(retval);
             writer.Flush();
        }
        public void TestConcatenateFieldsInbound()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                + "       <field name='FIRSTNAME'>//FirstName</field>"
                + "       <field name='LASTNAME'>//LastName</field>"
                + "       <field name='FULLNAME'>concat( //FirstName, ' ' , //LastName )</field>"
                + "</object></mappings></agent>";

            StudentPersonal sp = new StudentPersonal();
            sp.SetElementOrAttribute( "Name/FirstName", "Jimmy" );
            sp.SetElementOrAttribute( "Name/LastName", "Johnson" );

            IDictionary map = doInboundMapping( customMappings, sp );

            Assertion.AssertEquals( "First Name", "Jimmy", map["FIRSTNAME"] );
            Assertion.AssertEquals( "Last Name", "Johnson", map["LASTNAME"] );
            Assertion.AssertEquals( "Full Name", "Jimmy Johnson", map["FULLNAME"] );
        }
        public void TestVariableMapping()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                + "       <field name='STUDENT_NUM'>OtherIdList/OtherId[@Type='06']</field>"
                + "       <field name='HOMEROOM'>$STUDENT_NUM</field>"
                + "</object></mappings></agent>";

            StudentPersonal sp = new StudentPersonal();
            sp.SetElementOrAttribute( "OtherIdList/OtherId[@Type='06']", "998" );

            IDictionary map = doInboundMapping( customMappings, sp );

            Assertion.AssertEquals( "STUDENT_NUM", "998", map["STUDENT_NUM"] );
            Assertion.AssertEquals( "HOMEROOM", "998", map["HOMEROOM"] );

            Console.WriteLine( "HomeRoom = " + map["HOMEROOM"] );
        }
        public void TestConcatenateFieldsInbound020()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                +
                "       <field name='CITY_STATE_ZIP'>concat( AddressList/Address/City, ', ', AddressList/Address/StateProvince, '  ', AddressList/Address/PostalCode)</field>"
                + "</object></mappings></agent>";

            StudentPersonal sp = new StudentPersonal();
            sp.SetElementOrAttribute( "AddressList/Address[@Type='04']/City", "Chicago" );
            sp.SetElementOrAttribute( "AddressList/Address[@Type='04']/StateProvince", "IL" );
            sp.SetElementOrAttribute( "AddressList/Address[@Type='04']/PostalCode", "50001" );
            sp.SetElementOrAttribute( "Name/LastName", "Johnson" );

            Console.WriteLine( "StudentPersonal=" + sp.ToXml() );

            IDictionary map = doInboundMapping( customMappings, sp );

            String csz = (String) map["CITY_STATE_ZIP"];
            Console.WriteLine( "City State Zip=" + csz );
            Assertion.AssertEquals( "CityStateZip", "Chicago, IL  50001", map["CITY_STATE_ZIP"] );
        }
        public void testParseOnTimeGradYear()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Original'>1971</GradYear>"
                          + "</StudentPersonal>";

            StudentPersonal sp = (StudentPersonal) parseSIF15r1XML( sXML );
            sp = (StudentPersonal) AdkObjectParseHelper.WriteParseAndReturn( sp, SifVersion.SIF11 );
            Assertion.AssertNotNull( sp );
            Assertion.AssertNotNull( "On Time Grad Year", sp.OnTimeGraduationYear );
            Assertion.AssertEquals( "On Time Grad Year", 1971, (int) sp
                                                                         .OnTimeGraduationYear );

            Adk.SifVersion = SifVersion.SIF15r1;
            sp = new StudentPersonal();
            sp.SetElementOrAttribute( "GradYear[@Type='Original']", "8877" );
            Assertion.AssertNotNull( "On Time Grad Year", sp.OnTimeGraduationYear );
            Assertion.AssertEquals( "On Time Grad Year", 8877, (int) sp
                                                                         .OnTimeGraduationYear );

            Element gradValue = sp.GetElementOrAttribute( "GradYear[@Type='Original']" );
            Assertion.AssertNotNull( "On Time Grad Year", gradValue );
            int gradYear = (int) gradValue.SifValue.RawValue;
            Assertion.AssertNotNull( "On Time Grad Year", gradYear );
            Assertion.AssertEquals( "On Time Grad Year", 8877, gradYear );
        }
        public void testParseProjectedGradYear()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Projected'>2012</GradYear>"
                          + "</StudentPersonal>";

            StudentPersonal sp = (StudentPersonal) parseSIF15r1XML( sXML );
            sp = (StudentPersonal) AdkObjectParseHelper.WriteParseAndReturn( sp, SifVersion.SIF11 );
            Assertion.AssertNotNull( sp );
            Assertion.AssertNotNull( "Projected Grad Year", sp.ProjectedGraduationYear );
            Assertion.AssertEquals( "Projected Grad Year", 2012, (int) sp
                                                                           .ProjectedGraduationYear );

            Adk.SifVersion = SifVersion.SIF15r1;
            sp = new StudentPersonal();
            sp.SetElementOrAttribute( "GradYear[@Type='Projected']", "2089" );
            Assertion.AssertNotNull( "Projected Grad Year", sp.ProjectedGraduationYear );
            Assertion.AssertEquals( "Projected Grad Year", 2089, (int) sp
                                                                           .ProjectedGraduationYear );

            Element gradValue = sp.GetElementOrAttribute( "GradYear[@Type='Projected']" );
            Assertion.AssertNotNull( "Projected Grad Year", gradValue );
            int gradYear = (int) gradValue.SifValue.RawValue;
            Assertion.AssertNotNull( "Projected Grad Year", gradYear );
            Assertion.AssertEquals( "Projected Grad Year", 2089, gradYear );
        }