Пример #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);
        }