Exemplo n.º 1
0
        public void TestWriteXSINillMultiple()
        {
            SIF_Data data = new SIF_Data();

            for (int a = 0; a < 3; a++)
            {
                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));
                data.AddChild(sp);
            }



            SIF_Data data2 = (SIF_Data)AdkObjectParseHelper.WriteParseAndReturn(data, SifVersion.LATEST, null, true);

            foreach (SifElement child in data2.GetChildList())
            {
                StudentPersonal copy = (StudentPersonal)child;
                Name            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);

                SIF_ExtendedElement 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);
            }
        }