public void SharedChildren() { Adk.SifVersion = SifVersion.LATEST; StudentPersonal sp = new StudentPersonal(Adk.MakeGuid(), new Name(NameType.LEGAL, "hello", "world")); // Replace the existing demographics so there is no confusion Demographics d = new Demographics(); sp.Demographics = d; d.SetCountryOfBirth(CountryCode.US); CountriesOfCitizenship countries = new CountriesOfCitizenship(); d.CountriesOfCitizenship = countries; CountriesOfResidency residencies = new CountriesOfResidency(); d.CountriesOfResidency = residencies; countries.AddCountryOfCitizenship(CountryCode.Wrap("UK")); residencies.AddCountryOfResidency(CountryCode.Wrap("AU")); // overwrite the country codes again, just to try to repro the issue d.SetCountryOfBirth(CountryCode.Wrap("AA")); // Should overwrite the existing one //Remove the existing CountryOfCitizenship, add three more, and remove the middle one Assert.IsTrue(countries.Remove(CountryCode.Wrap("UK"))); countries.AddCountryOfCitizenship(CountryCode.Wrap("BB1")); countries.AddCountryOfCitizenship(CountryCode.Wrap("BB2")); countries.AddCountryOfCitizenship(CountryCode.Wrap("BB3")); Assert.IsTrue(countries.Remove(CountryCode.Wrap("BB2"))); // Remove the existing CountryOfResidency, add three more, and remove the first one Assert.IsTrue(residencies.Remove(CountryCode.Wrap("AU"))); residencies.AddCountryOfResidency(CountryCode.Wrap("CC1")); residencies.AddCountryOfResidency(CountryCode.Wrap("CC2")); residencies.AddCountryOfResidency(CountryCode.Wrap("CC3")); Assert.IsTrue(residencies.Remove(CountryCode.Wrap("CC1"))); StudentPersonal sp2 = AdkObjectParseHelper.runParsingTest(sp, SifVersion.LATEST); // The runParsingTest() method will compare the objects after writing them and reading them // back in, but to be completely sure, let's assert the country codes again // NOTE: Due to the .Net Array.Sort algorithm, repeatable elements come out in reverse order. // This doesn't appear to be a problem yet, but may be fixed in a future release. // For now, these tests look for the elements in reverse order Demographics d2 = sp2.Demographics; Assert.AreEqual("AA", d2.CountryOfBirth.ToString(), "Country of Birth"); Country[] citizenships = d2.CountriesOfCitizenship.ToArray(); Assert.AreEqual(2, citizenships.Length, "Should be two CountryOfCitizenships"); Assert.AreEqual("BB1", citizenships[0].TextValue, "First CountryOfCitizenship"); Assert.AreEqual("BB3", citizenships[1].TextValue, "Second CountryOfCitizenship"); // assert Country[] resid = d2.CountriesOfResidency.ToArray(); Assert.AreEqual(2, resid.Length, "Should be two CountryOfResidencys"); Assert.AreEqual("CC2", resid[0].TextValue, "First CountryOfResidencys"); Assert.AreEqual("CC3", resid[1].TextValue, "Second CountryOfResidencys"); }