Пример #1
0
        public void TestWriteXSINill()
        {
            StudentPersonal sp = new StudentPersonal();
               sp.RefId = Adk.MakeGuid();
               sp.StateProvinceId = "\u06DE55889";
               sp.LocalId = "987987987987987";
               Name name = new Name(NameType.LEGAL, "Johnson", "Steve");
               sp.Name = name;
               name.SetField( CommonDTD.NAME_TYPE, new SifString( null ) );
               name.SetField(CommonDTD.NAME_MIDDLENAME, new SifString(null));

               SIF_ExtendedElement see = new SIF_ExtendedElement("FOO", null );
               see.SetField(GlobalDTD.SIF_EXTENDEDELEMENT, new SifString(null));
               see.XsiType = "Integer";
               sp.SIFExtendedElementsContainer.Add(see);

               sp.SetField( StudentDTD.STUDENTPERSONAL_LOCALID, new SifString( null ) );

               Console.WriteLine(sp.ToXml());
               StudentPersonal copy = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.LATEST, null, true);
               Console.WriteLine(copy.ToXml());

               name = copy.Name;
               Assert.IsNull(name.Type);
               Assert.IsNull(name.MiddleName);
               Assert.IsNotNull(name.FirstName);
               Assert.IsNotNull(name.LastName);

               // Attributes cannot be represented using xs nil
               SimpleField field = name.GetField(CommonDTD.NAME_TYPE);
               Assert.IsNull(field);

               field = name.GetField(CommonDTD.NAME_MIDDLENAME);
               Assert.IsNotNull(field);
               Assert.IsNull(field.Value);

               see = copy.GetSIFExtendedElement("FOO");
               field = see.GetField(GlobalDTD.SIF_EXTENDEDELEMENT);
               Assert.IsNotNull(field);
               Assert.IsNull(field.Value);

               field = copy.GetField(StudentDTD.STUDENTPERSONAL_LOCALID);
               Assert.IsNotNull(field);
               Assert.IsNull(field.Value);
        }
Пример #2
0
        public void testInBoundMapping50000()
        {
            fCfg = new AgentConfig();
            fCfg
                .Read(
                "..\\..\\Library\\Tools\\Mapping\\MultiVersion.agent.cfg",
                false );

            int mappingIterations = 0;
            //
            // UNCOMMENT THIS LINE TO RUN THE SPEED TEST
            //
            // mappingIterations = 50000;

            Mappings mappings = fCfg.Mappings.GetMappings( "Default" );
            IDictionary map = buildIDictionaryForStudentPersonalTest();
            StringMapAdaptor sma = new StringMapAdaptor( map );

            // Fill out the student personal using outbound mappings first
            StudentPersonal template = new StudentPersonal();
            mappings.MapOutbound( sma, template );
            Console.WriteLine( template.ToXml() );

            DateTime start = DateTime.Now;
            for ( int x = 0; x < mappingIterations; x++ )
            {
                map.Clear();
                mappings.MapInbound( template, sma );
                if ( x%500 == 0 )
                {
                    Console.WriteLine( "Iteration " + x + " of "
                                       + mappingIterations );
                }
            }

            DateTime end = DateTime.Now;
            Console.WriteLine( "Mapping "
                               + mappingIterations
                               + " Students inbound took " + end.Subtract( start ) );
        }
        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"] );
        }
Пример #4
0
        public void testStudentPersonalSIF15r1()
        {
            IDictionary values = new Hashtable();
            values.Add( "PERMNUM", "9798" );
            values.Add( "SOCSECNUM", "845457898" );
            values.Add( "SCHOOLNUM", "999" );
            values.Add( "SCHOOLNUM2", "999" );
            values.Add( "GRADE", "09" );
            values.Add( "HOMEROOM", "5" );
            values.Add( "LASTNAME", "Doe" );
            values.Add( "FIRSTNAME", "Jane" );
            values.Add( "MIDDLENAME", null );
            values.Add( "NICKNAME", null );
            values.Add( "MAILADDR", "5845 Test Blvd" );
            values.Add( "CITY", "slc" );
            values.Add( "STATE", "Utah" );
            values.Add( "COUNTRY", "" );
            values.Add( "ZIPCODE", "84093" );
            values.Add( "RESADDR", null );
            values.Add( "RESCITY", null );
            values.Add( "RESSTATE", null );
            values.Add( "RESCOUNTRY", null );
            values.Add( "RESZIPCODE", null );
            values.Add( "BIRTHDATE", "20051209" );
            values.Add( "GENDER", "F" );
            values.Add( "ETHNICCODE", "W" );
            values.Add( "ENGPROF", "" );
            values.Add( "PRIMARYLNG", "" );
            values.Add( "TELEPHONE", null );

            StringMapAdaptor sma = new StringMapAdaptor( values );
            StudentPersonal sp = new StudentPersonal();

            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, sp, SifVersion.SIF15r1 );
            Console.WriteLine( sp.ToXml() );
            OtherIdList oil = sp.OtherIdList;
            bool gradeMappingFound = false;
            foreach ( OtherId oid in oil )
            {
                if ( "ZZ".Equals( oid.Type )
                     && oid.Value.StartsWith( "GRADE" ) )
                {
                    Assertion.AssertEquals( "OtherId[@Type=ZZ]GRADE: mapping", "GRADE:09", oid.Value );
                    gradeMappingFound = true;
                }
            }
            Assertion.Assert( "GradeMapping found", gradeMappingFound );
        }
Пример #5
0
        public void testStudentPersonalNullHomeroom()
        {
            IDictionary values = new Hashtable();
            values.Add( "PERMNUM", "9798" );
            values.Add( "SOCSECNUM", "845457898" );
            values.Add( "SCHOOLNUM", "999" );
            values.Add( "SCHOOLNUM2", "999" );
            values.Add( "GRADE", "09" );
            values.Add( "HOMEROOM", null );
            values.Add( "LASTNAME", "Doe" );
            values.Add( "FIRSTNAME", "Jane" );
            values.Add( "MIDDLENAME", null );
            values.Add( "NICKNAME", null );
            values.Add( "MAILADDR", "5845 Test Blvd" );
            values.Add( "CITY", "slc" );
            values.Add( "STATE", "Utah" );
            values.Add( "COUNTRY", "" );
            values.Add( "ZIPCODE", "84093" );
            values.Add( "RESADDR", null );
            values.Add( "RESCITY", null );
            values.Add( "RESSTATE", null );
            values.Add( "RESCOUNTRY", null );
            values.Add( "RESZIPCODE", null );
            values.Add( "BIRTHDATE", "20051209" );
            values.Add( "GENDER", "F" );
            values.Add( "ETHNICCODE", "W" );
            values.Add( "ENGPROF", "" );
            values.Add( "PRIMARYLNG", "" );
            values.Add( "TELEPHONE", null );

            StringMapAdaptor sma = new StringMapAdaptor( values );
            StudentPersonal sp = new StudentPersonal();

            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, sp, SifVersion.SIF15r1 );

            Console.WriteLine( sp.ToXml() );

            Element e = sp
                .GetElementOrAttribute( "OtherId[@Type='ZZ' and starts-with(., 'HOMEROOM') ]" );
            Assertion.AssertNull( "HOMEROOM should not have been mapped", e );
        }
Пример #6
0
        public void testStudentPersonal2Addresses20r1()
        {
            IDictionary values = new Hashtable();
            values.Add( "PERMNUM", "9798" );
            values.Add( "LASTNAME", "Doe" );
            values.Add( "FIRSTNAME", "Jane" );
            values.Add( "MIDDLENAME", null );
            values.Add( "MAILADDR", "PO Box 80077" );
            values.Add( "CITY", "Salt Lake City" );
            values.Add( "STATE", "Utah" );
            values.Add( "COUNTRY", "US" );
            values.Add( "ZIPCODE", "84093" );
            values.Add( "RESADDR", "528 Big CottonWood Rd" );
            values.Add( "RESCITY", "Sandy" );
            values.Add( "RESSTATE", "UT" );
            values.Add( "RESCOUNTRY", "US" );
            values.Add( "RESZIPCODE", "84095" );

            StringMapAdaptor sma = new StringMapAdaptor( values );
            StudentPersonal sp = new StudentPersonal();

            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, sp, SifVersion.SIF20r1 );

            Console.WriteLine( sp.ToXml() );

            Element e = sp
                .GetElementOrAttribute( "AddressList/Address[@Type='0123']/Street/Line1" );
            Assertion.AssertNotNull( "Mailing Address was not mapped ", e );
            Assertion.AssertEquals( "Mailing Address", "PO Box 80077", e.TextValue );

            e = sp
                .GetElementOrAttribute( "AddressList/Address[@Type='0765']/Street/Line1" );
            Assertion.AssertNotNull( "Residential Address was not mapped ", e );
            Assertion.AssertEquals( "Mailing Address", "528 Big CottonWood Rd", e
                                                                                    .TextValue );

            StudentAddressList[] list = sp.AddressLists;
            SifElementList children = sp.GetChildList( CommonDTD.ADDRESSLIST );
            Assertion.AssertEquals( "Should have one StudentAddress elements", 1,
                                    children.Count );
            Assertion.AssertEquals( "Should have two address elements", 2, children[0].ChildCount );
        }
Пример #7
0
        public void testOutBoundMappingContext50000()
        {
            fCfg = new AgentConfig();
            fCfg
                .Read(
                "..\\..\\Library\\Tools\\Mapping\\MultiVersion.agent.cfg",
                false );

            int mappingIterations = 0;
            //
            // UNCOMMENT THIS LINE TO RUN THE SPEED TEST
            //
            //mappingIterations = 50000;

            Mappings mappings = fCfg.Mappings.GetMappings( "Default" );
            IDictionary map = buildIDictionaryForStudentPersonalTest();
            StringMapAdaptor sma = new StringMapAdaptor( map );
            StudentPersonal template = new StudentPersonal();

            MappingsContext mc = mappings.SelectOutbound( template.ElementDef,
                                                          SifVersion.SIF20, null, null );
            mc.Map( template, sma );
            Console.WriteLine( template.ToXml() );

            DateTime start = DateTime.Now;
            for ( int x = 0; x < mappingIterations; x++ )
            {
                template = new StudentPersonal();
                mc.Map( template, sma );
                if ( x%500 == 0 )
                {
                    Console.WriteLine( "Iteration " + x + " of "
                                       + mappingIterations );
                }
            }
            Console.WriteLine( template.ToXml() );
            DateTime end = DateTime.Now;
            Console.WriteLine( "Mapping "
                               + mappingIterations
                               + " Students inbound took " + end.Subtract( start ) );
        }
Пример #8
0
        public void TestWriteXSIType()
        {
            StudentPersonal sp = new StudentPersonal();
               sp.RefId = Adk.MakeGuid();
               sp.StateProvinceId = "\u06DE55889";
               sp.LocalId = "987987987987987";

               SIF_ExtendedElement see = new SIF_ExtendedElement( "FOO", "BAR" );
               see.XsiType = "Integer";
               sp.SIFExtendedElementsContainer.Add( see );

               Console.WriteLine( sp.ToXml() );

               StudentPersonal copy =
               (StudentPersonal) AdkObjectParseHelper.WriteParseAndReturn( sp, SifVersion.LATEST, null, true );

               see = copy.SIFExtendedElements[0];

               Assert.IsNotNull( see );
               Assert.AreEqual( "Integer", see.XsiType );
        }