public void TestConcatenateFields()
        {
            String configFileText = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                                    + "    <mappings id=\"Default\">"
                                    + "        <object object=\"StudentPersonal\">"
                                    + "            <field name=\"StudentPers_guid\">@RefId</field>"
                                    + "            <field name=\"LastName\">Name[@Type='01']/LastName</field>"
                                    + "            <field name=\"FirstName\">Name[@Type='01']/FirstName</field>"
                                    + "            <field name=\"MiddleName\">Name[@Type='01']/MiddleName</field>"
                                    +
                                    "            <field name=\"FullName\">Name[@Type='01']/FullName=$(LastName), $(FirstName) $(MiddleName)</field>"
                                    + "        </object>" + "    </mappings>" + "</agent>";

            IDictionary map = new Dictionary<String, String>();
            map.Add( "StudentPers_guid", "1234" );
            map.Add( "LastName", "Finale" );
            map.Add( "FirstName", "Prima" );
            map.Add( "MiddleName", "Mediccio" );

            map.Add( "FullName", "" );
            StringMapAdaptor sma = new StringMapAdaptor( map );
            TestValueBuilder tvb = new TestValueBuilder( sma );
            StudentPersonal sp = mapToStudentPersonal( sma, configFileText, tvb );

            Assertion.AssertNotNull( "Student should not be null", sp );

            SimpleField fullName = (SimpleField) sp
                                                     .GetElementOrAttribute( "Name/FullName" );
            Assertion.AssertNotNull( "FullName", fullName );
            Assertion.AssertEquals( "FullName", "Finale, Prima Mediccio", fullName.Value );
        }
Esempio n. 2
0
        public void TestCustomFunctionOutbound()
        {
            String flattenDateFunctionCall = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                                             + "    <mappings id=\"Default\">"
                                             + "        <object object=\"StudentPersonal\">"
                                             + "          <field name=\"StudentPers_guid\">@RefId</field>"
                                             +
                                             "          <field name=\"DOB\">Demographics/BirthDate=@flattenDate( $(DOB) )</field>"
                                             + "        </object>"
                                             + "    </mappings>"
                                             + "</agent>";

            IDictionary map = new Dictionary <String, String>();

            map.Add("StudentPers_guid", "1234");
            map.Add("DOB", "19900904");
            StringMapAdaptor sma = new StringMapAdaptor(map);
            TestValueBuilder tvb = new TestValueBuilder(sma);

            DefaultValueBuilder.AddAlias("flattenDate", GetType().AssemblyQualifiedName);
            Adk.SifVersion = SifVersion.SIF20;
            StudentPersonal sp = mapToStudentPersonal(sma, flattenDateFunctionCall, tvb);

            Assertion.Assert("flattenDate should have been called", tvb.WasCalled);
            Assertion.AssertNotNull("Student should not be null", sp);
            Assertion.AssertNotNull("BirthDate should not be null", sp.Demographics.BirthDate);
        }
Esempio n. 3
0
        public void TestStringConcat()
        {
            String configFileText = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                                    + "    <mappings id=\"Default\">"
                                    + "        <object object=\"StudentPersonal\">"
                                    +
                                    "            <field name=\"FullName\">Name[@Type='01']/FullName=NAME:$(LastName), $(FirstName) $(MiddleName)</field>"
                                    + "        </object>" + "    </mappings>" + "</agent>";

            IDictionary map = new Dictionary <String, String>();

            map.Add("StudentPers_guid", "1234");
            map.Add("LastName", "Finale");
            map.Add("FirstName", "Prima");
            map.Add("MiddleName", "Mediccio");
            map.Add("FullName", "");

            StringMapAdaptor sma = new StringMapAdaptor(map);
            TestValueBuilder tvb = new TestValueBuilder(sma);
            StudentPersonal  sp  = mapToStudentPersonal(sma, configFileText, tvb);

            Assertion.AssertNotNull("Student should not be null", sp);

            SimpleField fullName = (SimpleField)sp
                                   .GetElementOrAttribute("Name/FullName");

            Assertion.AssertNotNull("FullName", fullName);
            Assertion.AssertEquals("FullName", "NAME:Finale, Prima Mediccio", fullName.Value);
        }
        public void TestCustomFunctionOutbound()
        {
            String flattenDateFunctionCall = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                                             + "    <mappings id=\"Default\">"
                                             + "        <object object=\"StudentPersonal\">"
                                             + "          <field name=\"StudentPers_guid\">@RefId</field>"
                                             +
                                             "          <field name=\"DOB\">Demographics/BirthDate=@flattenDate( $(DOB) )</field>"
                                             + "        </object>"
                                             + "    </mappings>"
                                             + "</agent>";

            IDictionary map = new Dictionary<String, String>();
            map.Add( "StudentPers_guid", "1234" );
            map.Add( "DOB", "19900904" );
            StringMapAdaptor sma = new StringMapAdaptor( map );
            TestValueBuilder tvb = new TestValueBuilder( sma );
            DefaultValueBuilder.AddAlias( "flattenDate", GetType().AssemblyQualifiedName );
            Adk.SifVersion = SifVersion.SIF20;
            StudentPersonal sp = mapToStudentPersonal( sma, flattenDateFunctionCall, tvb );
            Assertion.Assert( "flattenDate should have been called", tvb.WasCalled );
            Assertion.AssertNotNull( "Student should not be null", sp );
            Assertion.AssertNotNull( "BirthDate should not be null", sp.Demographics.BirthDate );
        }