public void testParseProjectedGradYear() { String sXML = "<StudentPersonal RefId='12345678901234567890'>" + " <GradYear Type='Projected'>2012</GradYear>" + "</StudentPersonal>"; StudentPersonal sp = (StudentPersonal)parseSIF15r1XML(sXML); sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11); Assertion.AssertNotNull(sp); Assertion.AssertNotNull("Projected Grad Year", sp.ProjectedGraduationYear); Assertion.AssertEquals("Projected Grad Year", 2012, (int)sp .ProjectedGraduationYear); Adk.SifVersion = SifVersion.SIF15r1; sp = new StudentPersonal(); sp.SetElementOrAttribute("GradYear[@Type='Projected']", "2089"); Assertion.AssertNotNull("Projected Grad Year", sp.ProjectedGraduationYear); Assertion.AssertEquals("Projected Grad Year", 2089, (int)sp .ProjectedGraduationYear); Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Projected']"); Assertion.AssertNotNull("Projected Grad Year", gradValue); int gradYear = (int)gradValue.SifValue.RawValue; Assertion.AssertNotNull("Projected Grad Year", gradYear); Assertion.AssertEquals("Projected Grad Year", 2089, gradYear); }
public void testParseGraduationDateSS() { String sXML = "<StudentSnapshot StudentPersonalRefId='12345678901234567890'>" + " <GradYear Type='Actual'>2005</GradYear>" + "</StudentSnapshot>"; StudentSnapshot sp = (StudentSnapshot)parseSIF15r1XML(sXML); sp = (StudentSnapshot)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF15r1); Assertion.AssertNotNull(sp); PartialDateType gd = sp.GraduationDate; Assertion.AssertNotNull("Actual Grad Year", gd); Assertion.AssertEquals("Actual Grad Year", 2005, (int)gd.Year); Adk.SifVersion = SifVersion.SIF15r1; sp = new StudentSnapshot(); sp.SetElementOrAttribute("GradYear[@Type='Actual']", "2054"); gd = sp.GraduationDate; Assertion.AssertNotNull("Actual Grad Year", gd); Assertion.AssertEquals("Actual Grad Year", 2054, (int)gd.Year); Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Actual']"); Assertion.AssertNotNull("Actual Grad Year", gradValue); Assert.IsTrue(gradValue is PartialDateType, "Should be a partial date type"); PartialDateType gradYear = (PartialDateType)gradValue; Assertion.AssertEquals("Actual Grad Year", 2054, gradYear.Year.Value); }
public void testParseOnTimeGradYear() { String sXML = "<StudentPersonal RefId='12345678901234567890'>" + " <GradYear Type='Original'>1971</GradYear>" + "</StudentPersonal>"; StudentPersonal sp = (StudentPersonal)parseSIF15r1XML(sXML); sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11); Assertion.AssertNotNull(sp); Assertion.AssertNotNull("On Time Grad Year", sp.OnTimeGraduationYear); Assertion.AssertEquals("On Time Grad Year", 1971, (int)sp .OnTimeGraduationYear); Adk.SifVersion = SifVersion.SIF15r1; sp = new StudentPersonal(); sp.SetElementOrAttribute("GradYear[@Type='Original']", "8877"); Assertion.AssertNotNull("On Time Grad Year", sp.OnTimeGraduationYear); Assertion.AssertEquals("On Time Grad Year", 8877, (int)sp .OnTimeGraduationYear); Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Original']"); Assertion.AssertNotNull("On Time Grad Year", gradValue); int gradYear = (int)gradValue.SifValue.RawValue; Assertion.AssertNotNull("On Time Grad Year", gradYear); Assertion.AssertEquals("On Time Grad Year", 8877, gradYear); }
public void SDOParse() { // Create a StudentPersonal StudentPersonal sp = ObjectCreator.CreateStudentPersonal(); // Test changing the name sp.Name = new Name(NameType.BIRTH, "STUDENT", "JOE"); sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF15r1); // Test to ensure that Email is not a child of StudentPersonal Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count); Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList); Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0); sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF20); // Test to ensure that Email is not a child of StudentPersonal Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count); Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList); Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0); sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF11); // Test to ensure that Email is not a child of StudentPersonal Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count); Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList); Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0); sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF22); // Test to ensure that Email is not a child of StudentPersonal Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count); Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList); Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0); }
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"); }
public void testStudentMealMappings() { StudentMeal sm = new StudentMeal(); Mappings mappings = fCfg.Mappings.GetMappings("Default"); IDictionary map = new Hashtable(); map.Add("Balance", "10.55"); StringMapAdaptor sma = new StringMapAdaptor(map); mappings.MapOutbound(sma, sm); sm = (StudentMeal)AdkObjectParseHelper.WriteParseAndReturn(sm, fVersion); // Assert that the object was mapped correctly FSAmounts amounts = sm.Amounts; Assertion.AssertNotNull(amounts); FSAmount amount = amounts.ItemAt(0); Assertion.Assert(amount.Value.HasValue); Assertion.AssertEquals(10.55, amount.Value.Value); // Now, map the object back to a hashmap and assert it IDictionary restoredData = new Hashtable(); sma = new StringMapAdaptor(restoredData); mappings.MapInbound(sm, sma); assertMapsAreEqual(map, restoredData); }
public void SDOParse() { DateTime today = DateTime.Now; Demographics demo = new Demographics(); demo.CountriesOfCitizenship = new CountriesOfCitizenship(); demo.CountriesOfCitizenship.AddCountryOfCitizenship(CountryCode.US); demo.CountriesOfCitizenship.AddCountryOfCitizenship(CountryCode.Wrap("CA")); demo.CountriesOfResidency = new CountriesOfResidency(new Country(CountryCode.Wrap("CA"))); demo.CountryOfBirth = CountryCode.US.ToString(); // Create a StudentPlacement StudentPlacement sp = new StudentPlacement(); sp.RefId = Adk.MakeGuid(); sp.StudentParticipationRefId = Adk.MakeGuid(); sp.StudentPersonalRefId = Adk.MakeGuid(); sp.SetService(ServiceCode.STAFF_PROFESSIONAL_DEVELOPMENT, "foo", "test"); sp.ServiceProviderAgency = "ABSD"; sp.ServiceProviderName = "John Smithfield"; sp.SetServiceSetting("asdfasdf", ServiceSettingCode.REGULAR_SCHOOL_CAMPUS); sp.StartDate = today; sp.FrequencyTime = new FrequencyTime(); sp.SetIndirectTime(DurationUnit.MINUTES, 10); sp.TotalServiceDuration = new TimeUnit(DurationUnit.MINUTES, 5); sp.SpecialNeedsTransportation = false; sp.AssistiveTechnology = true; sp.SetDirectTime(DurationUnit.HOURS, 5); AdkObjectParseHelper.runParsingTest(sp, SifVersion.LATEST); }
public void testParseGraduationDate() { String sXML = "<StudentPersonal RefId='12345678901234567890'>" + " <GradYear Type='Actual'>2005</GradYear>" + "</StudentPersonal>"; StudentPersonal sp = (StudentPersonal)parseSIF15r1XML(sXML); sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11); Assertion.AssertNotNull(sp); PartialDateType gd = sp.GraduationDate; Assertion.AssertNotNull("Actual Grad Year", gd); Assertion.AssertEquals("Actual Grad Year", 2005, (int)gd.Year); Adk.SifVersion = SifVersion.SIF15r1; sp = new StudentPersonal(); sp.SetElementOrAttribute("GradYear[@Type='Actual']", "2054"); gd = sp.GraduationDate; Assertion.AssertNotNull("Actual Grad Year", gd); Assertion.AssertNotNull("GraduationDate/getYear()", gd.Year); Assertion.AssertEquals("Actual Grad Year", 2054, gd.Year.Value); Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Actual']"); Assertion.AssertNotNull("Actual Grad Year", gradValue); PartialDateType pdt = (PartialDateType)gradValue; Assertion.AssertEquals("Actual Grad Year", 2054, pdt.Year.Value); }
public void testReadWriteStaffAssignmentSIF2x() { StaffAssignment sa = ObjectCreator.CreateStaffAssignment(); sa = (StaffAssignment)AdkObjectParseHelper.WriteParseAndReturn(sa, SifVersion.SIF20r1); Assertion.AssertEquals("Primary Assignment", "Yes", sa.PrimaryAssignment); }
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); } }
public void testReadWriteStaffAssignmentSIF1x() { StaffAssignment sa = ObjectCreator.CreateStaffAssignment(); Console.WriteLine(sa.GetContent().Count); sa = (StaffAssignment)AdkObjectParseHelper.WriteParseAndReturn(sa, SifVersion.SIF15r1); Assertion.AssertNull("Primary Assignment", sa.PrimaryAssignment); }
public void TestEncodingHighAsciiChars() { StudentPersonal sp = new StudentPersonal(); sp.RefId = Adk.MakeGuid(); sp.StateProvinceId = "\u06DE55889"; sp.LocalId = "987987987987987"; StudentPersonal copy = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.LATEST); Assert.AreEqual("\u06DE55889", copy.StateProvinceId, "LocalID, Encoded"); }
/// <summary> /// Tests the SifEncryption Class using clear text encryption /// </summary> //[Test, Explicit] //public void TestRSAEncryption() //{ // // This test is not currently run with the full suite of tests because support for RSA encryption is // // not implemented in the ADK // SifEncryption encr = SifEncryption.GetInstance(PasswordAlgorithm.RSA, "SECRET_KEY_RSA", null); // AssertEncryption(encr, DEFAULT_ENCRYPTED_STRING); //} /// <summary> /// Asserts that the password is encrypted and decrypted properly and returns the AuthenticationInfo /// object that was produced in test for further assertions, if necessary /// </summary> /// <param name="encryptor"></param> /// <param name="passwordText"></param> /// <returns></returns> private AuthenticationInfo AssertEncryption(SifEncryption encryptor, string passwordText) { AuthenticationInfo returnValue = null; Authentication auth = CreateAuthentication(); AuthenticationInfo inf = auth.AuthenticationInfo; inf.PasswordList = new PasswordList(); inf.PasswordList.Add(new Password()); // Encrypt the password encryptor.WritePassword(inf.PasswordList.ItemAt(0), passwordText); // Write the object to and and read from xml to assure that the values are being persisted properly Authentication reparsedAuth = (Authentication)AdkObjectParseHelper.WriteParseAndReturn(auth, Adk.SifVersion); returnValue = reparsedAuth.AuthenticationInfo; SifEncryption decryptor = SifEncryption.GetInstance(PasswordAlgorithm.Wrap(returnValue.PasswordList.ItemAt(0).Algorithm), encryptor.KeyName, encryptor.Key); string decryptedValue = decryptor.ReadPassword(returnValue.PasswordList.ItemAt(0)); if (encryptor.IsHash) { // Assert that the decrypted value is the same as the AuthenticationInfoPassword's text value Assert.AreEqual(returnValue.PasswordList.ItemAt(0).TextValue, decryptedValue, "Hashed implementation of ReadPassword() should return the Base64 value"); // Assert that the hash is correct HashAlgorithm hasher = null; if (returnValue.PasswordList.ItemAt(0).Algorithm == PasswordAlgorithm.SHA1.Value) { hasher = new SHA1CryptoServiceProvider(); } else if (returnValue.PasswordList.ItemAt(0).Algorithm == PasswordAlgorithm.MD5.Value) { hasher = new MD5CryptoServiceProvider(); } byte[] preHashed = Encoding.UTF8.GetBytes(passwordText); byte[] hashed = hasher.ComputeHash(preHashed); string textHash = Convert.ToBase64String(hashed); ((IDisposable)hasher).Dispose(); Assert.AreEqual(textHash, decryptedValue, "Hash values do not match"); } else { Assert.AreEqual(passwordText, decryptedValue, "Decypted value differs from original value."); } return(returnValue); }
public void testSSE_Get_XPathSurrogate_SIF15r1() { Adk.SifVersion = SifVersion.SIF15r1; String sXML = "<StudentSchoolEnrollment RefId=\"A8C3D3E34B359D75101D00AA001A1652\"" + " StudentPersonalRefId=\"D3E34B359D75101A8C3D00AA001A1652\"" + " SchoolInfoRefId=\"D3E34B359D75101A8C3D00AA001A1651\"" + " MembershipType=\"Home\"" + " TimeFrame=\"Current\">" + " <SchoolYear>2004</SchoolYear>" + " <EntryDate>20040129</EntryDate>" + " <EntryType Code=\"D05\"/>" + " <GradeLevel Code=\"10\"/>" + " <Homeroom RoomInfoRefId=\"D7510D3E34B3591A8C3D00AA001A1651\"/>" + " <StaffAssigned Type=\"Advisor\" StaffPersonalRefId=\"B359D3E34D75101A8C3D00AA001A1652\"/>" + " <FTE>1.00</FTE>" + " <FTPTStatus>FullTime</FTPTStatus>" + " <ResidencyStatus>1653</ResidencyStatus>" + " <NonResidentAttendReason>1658</NonResidentAttendReason>" + " </StudentSchoolEnrollment> "; StudentSchoolEnrollment sse = (StudentSchoolEnrollment)parseSIF15r1XML(sXML); sse = (StudentSchoolEnrollment)AdkObjectParseHelper.WriteParseAndReturn(sse, SifVersion.SIF15r1); Assertion.AssertNotNull(sse); // Check getting Homeroom and Residency status using APIs Assertion.AssertNotNull("Homeroom", sse.Homeroom); Assertion.AssertEquals("Homeroom", "D7510D3E34B3591A8C3D00AA001A1651", sse.Homeroom.Value); ResidencyStatus rs = sse.ResidencyStatus; Assertion.AssertNotNull("ResidencyStatus", rs); Assertion.AssertEquals("ResidencyStatus", "1653", rs.Code); // Check getting Homeroom and Residency status using SIF 1.5 xpaths // Homeroom Element value = sse.GetElementOrAttribute("Homeroom/@RoomInfoRefId"); Assertion.AssertNotNull("Homeroom", value); Assertion.AssertEquals("Homeroom", "D7510D3E34B3591A8C3D00AA001A1651", value.TextValue); // ResidencyStatus value = sse.GetElementOrAttribute("ResidencyStatus"); Assertion.AssertNotNull("ResidencyStatus", value); Assertion.AssertEquals("ResidencyStatus", "1653", value.TextValue); }
public void WriteXml() { if (Adk.SifVersion < SifVersion.SIF15r1) { return; } LearningStandardDocument doc = new LearningStandardDocument(); doc.RefId = "A5A575C789175101B8E7F08ED123A823"; doc.Language = "en-us"; doc.Title = "Washington Essential Academic Learning Requirements"; doc.Description = "This document addresses high school English Language Arts"; doc.Source = "State"; doc.Organizations = new Organizations(new Organization("State of Washington")); doc.Authors = new Authors(new Author("McREL")); doc.OrganizationContactPoint = "http://www.mcrel.org"; doc.SubjectAreas = new SubjectAreas(new SubjectArea("10")); doc.DocumentStatus = "Adopted"; doc.DocumentDate = new DateTime(2001, 4, 15); doc.LocalAdoptionDate = new DateTime(2002, 1, 6); doc.EndOfLifeDate = new DateTime(2003, 4, 15); doc.Copyright = new Copyright(); doc.Copyright.Date = new DateTime(2001, 02, 04); doc.Copyright.Holder = "State of Washington"; doc.GradeLevels = new GradeLevels(); doc.GradeLevels.AddGradeLevel(GradeLevelCode.C09); doc.GradeLevels.AddGradeLevel(GradeLevelCode.C10); doc.GradeLevels.AddGradeLevel(GradeLevelCode.C11); doc.GradeLevels.AddGradeLevel(GradeLevelCode.C12); doc.RepositoryDate = new DateTime(2001, 04, 15); doc.LearningStandardItemRefId = "B7D26D789139214A8C7F08EA123A8234"; doc.RelatedLearningStandards = new RelatedLearningStandards(new LearningStandardDocumentRefId("B216162FC98D202E62A64D53C991A25A")); string xml = doc.ToXml(); Console.WriteLine(xml); // Mainly, we want to test for the lang element to be written properly XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); XmlAttribute langAttr = xmlDoc.DocumentElement.Attributes["lang", "http://www.w3.org/XML/1998/namespace"]; Assert.AreEqual("http://www.w3.org/XML/1998/namespace", langAttr.NamespaceURI); LearningStandardDocument lsDoc2 = (LearningStandardDocument)AdkObjectParseHelper.runParsingTest(doc, SifVersion.LATEST); Assert.AreEqual("en-us", lsDoc2.Language, "xml:lang"); }
public void SDOParse() { ReportManifest rm = new ReportManifest(); rm.RefId = "C234516384746B387459000F84723A00"; rm.ReportAuthorityInfoRefId = "84756373645746363738484848484832"; SIF_Version version = new SIF_Version(); version.SifVersion = SifVersion.LATEST; rm.SIF_Version = version.ToString(); rm.SetReceivingAuthority("84756373645746363738484848484812", ""); rm.ReportName = "December 1 IDEA Students"; rm.Description = "A report of all IDEA-eligible students receiving services on December 1"; ReportingPeriod period = new ReportingPeriod(); period.BeginReportDate = new DateTime?(new DateTime(2003, 12, 01)); period.EndReportDate = new DateTime?(new DateTime(2003, 12, 01)); period.BeginSubmitDate = new DateTime?(new DateTime(2003, 12, 01)); period.EndSubmitDate = new DateTime?(new DateTime(2003, 12, 01)); period.DueDate = new DateTime?(new DateTime(2003, 12, 01)); rm.ReportingPeriod = period; rm.SetReportDefinitionSource(ReportDefinitionSourceType.URL, "http://www.state.edu/IDEAEligible.html"); SIF_QueryGroup group = new SIF_QueryGroup(); rm.SIF_QueryGroup = group; SIF_Query query = new SIF_Query(); query.SetSIF_QueryObject("StudentPersonal"); group.Add(query); query = new SIF_Query(); group.Add(query); query.SetSIF_QueryObject("StudentSchoolEnrollment"); SIF_ConditionGroup condGroup = new SIF_ConditionGroup(); SIF_Conditions conds = new SIF_Conditions(); conds.AddSIF_Condition("EntryDate", Operators.EQ, "20031201"); condGroup.AddChild(conds); query.SIF_ConditionGroup = condGroup; // NOTE: This will currently fail every time, due to a bug in // CompareGraphTo AdkObjectParseHelper.runParsingTest(rm, SifVersion.LATEST); }
public void testSettingNullCountryArrivalDate() { StudentPersonal sp = ObjectCreator.CreateStudentPersonal(); Demographics d = sp.Demographics; d.CountryArrivalDate = new DateTime(1997, 5, 1); Assert.AreEqual(new DateTime(1997, 5, 1), d.CountryArrivalDate); d.CountryArrivalDate = null; Assert.IsNull(d.CountryArrivalDate, "CountryArrivalDate was set to null"); sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, Adk.SifVersion); d = sp.Demographics; Assert.IsNull(d.CountryArrivalDate, "After reparsing it should still be null"); }
private void ParseSingleSDOObjectFromFile(string fileName) { // Parse the object from the file Console.WriteLine("Parsing from file..."); SifParser p = SifParser.NewInstance(); SifDataObject sifObject = null; using (Stream inStream = GetResourceStream(fileName)) { sifObject = (SifDataObject)p.Parse(inStream, null, SifParserFlags.None, SifVersion.SIF15r1); inStream.Close(); } Assert.IsNotNull(sifObject); AdkObjectParseHelper.runParsingTest(sifObject, SifVersion.SIF15r1); }
public void ParseSectionInfoWithOverride() { // Parse the object from the file Console.WriteLine("Parsing from file..."); SifParser p = SifParser.NewInstance(); SIF_Event sifEvent = null; using (Stream inStream = GetResourceStream("SectionInfo_SchoolCourseInfoOverride.xml")) { sifEvent = (SIF_Event)p.Parse(inStream, null, SifParserFlags.None, SifVersion.SIF15r1); inStream.Close(); } Assert.IsNotNull(sifEvent); AdkObjectParseHelper.runParsingTest((SifDataObject)sifEvent.SIF_ObjectData.SIF_EventObject.GetChildList()[0], SifVersion.SIF15r1); }
public void ParseSIF_LogEntry() { // This test attempts to parse SIF_LogEntry, Console.WriteLine("Parsing from file..."); SifParser p = SifParser.NewInstance(); SIF_LogEntry logMsg = null; using (Stream inStream = GetResourceStream("SIF_LogEntry.xml")) { logMsg = (SIF_LogEntry)p.Parse(inStream, null, SifParserFlags.None, SifVersion.SIF15r1); inStream.Close(); } Assert.IsNotNull(logMsg); AdkObjectParseHelper.runParsingTest(logMsg, SifVersion.LATEST); }
public void ParseLibraryPatronStatus() { // This test attempts to parse LibraryPatronStatus, which had a problem with parsing // Child elements that were SIFTime // Parse the object from the file Console.WriteLine("Parsing from file..."); SifParser p = SifParser.NewInstance(); SIF_Response msg = null; using (Stream inStream = GetResourceStream("LibraryPatronStatus.xml")) { msg = (SIF_Response)p.Parse(inStream, null); inStream.Close(); } Assert.IsNotNull(msg); AdkObjectParseHelper.runParsingTest((SifDataObject)msg.SIF_ObjectData.GetChildList()[0], SifVersion.SIF15r1); }
public void FilterOutElementsFromDifferentVersion() { Adk.SifVersion = SifVersion.SIF11; StudentPersonal sp = ObjectCreator.CreateStudentPersonal(); sp.StateProvinceId = "55889"; sp.LocalId = "987987987987987"; StudentPersonal sp11 = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11); Assertion.AssertNull("LocalID", sp11.LocalId); Assertion.AssertNull("StatePRID", sp11.StateProvinceId); StudentPersonal sp15 = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF15r1); Assertion.AssertNotNull("LocalID", sp15.LocalId); Assertion.AssertNotNull("StatePRID", sp15.StateProvinceId); }
public void testSIF_Provision010() { SIF_Provision prov = new SIF_Provision(); SIF_PublishAddObjects spao = new SIF_PublishAddObjects(); spao.Add(new SIF_Object("Authentication")); prov.SIF_PublishAddObjects = spao; prov = (SIF_Provision)AdkObjectParseHelper.WriteParseAndReturn((SifElement)prov, Adk.SifVersion); spao = prov.SIF_PublishAddObjects; Assertion.AssertNotNull("SIF_PublishAddObjects", spao); Assertion.AssertEquals("spao child count", 1, spao.ChildCount); SIF_Object so = (SIF_Object)spao.GetChild(InfraDTD.SIF_PUBLISHADDOBJECTS_SIF_OBJECT, new string[] { "Authentication" }); Assertion.AssertNotNull("SIF_Object", so); }
public void testStudentPlacementMapping() { StudentPlacement sp = new StudentPlacement(); Mappings mappings = fCfg.Mappings.GetMappings("Default"); IDictionary map = buildIDictionaryForStudentPlacementTest(); StringMapAdaptor sma = new StringMapAdaptor(map); mappings.MapOutbound(sma, sp); sp = (StudentPlacement)AdkObjectParseHelper.WriteParseAndReturn(sp, fVersion); // Assert that the StudentPlacement object was mapped correctly assertStudentPlacement(sp); // Now, map the StudentPlacement back to a hashmap and assert it IDictionary restoredData = new Hashtable(); sma = new StringMapAdaptor(restoredData); mappings.MapInbound(sp, sma); assertMapsAreEqual(map, restoredData); }
public void SDOParse() { ReportAuthorityInfo info = new ReportAuthorityInfo(); info.AuthorityName = "XX State Department of Education"; info.AuthorityId = "StateDOEDataWarehouse"; info.AuthorityDepartment = "Bureau of Special Education"; info.SetAuthorityLevel(AuthorityLevel.STATE); ContactInfo contact = new ContactInfo(); contact.SetName(NameType.NAME_OF_RECORD, "Theodore", "Geisel"); contact.PositionTitle = "State Superintendent"; contact.EmailList = new EmailList(new Email(EmailType.PRIMARY, "*****@*****.**")); contact.PhoneNumberList = new PhoneNumberList(new PhoneNumber(PhoneNumberType.SIF1x_WORK_PHONE, "(555) 555-0000")); info.ContactInfo = contact; AdkObjectParseHelper.runParsingTest(info, SifVersion.LATEST); }
public void ParseSectionInfo() { // Parse the object from the file Console.WriteLine("Parsing from file..."); SifParser p = SifParser.NewInstance(); SectionInfo sectionInfo = null; using (Stream inStream = GetResourceStream("SectionInfo.xml")) { sectionInfo = (SectionInfo)p.Parse(inStream, null, SifParserFlags.None, SifVersion.SIF15r1); inStream.Close(); } Assert.IsNotNull(sectionInfo); ScheduleInfoList schedules = sectionInfo.ScheduleInfoList; Assert.AreEqual(2, schedules.Count, "Should have two ScheduleInfo elements"); ScheduleInfo[] scheds = schedules.ToArray(); // Assert the first ScheduleInfo Assert.AreEqual(2, scheds[0].TeacherList.Count, "Should have two teachers"); Assert.AreEqual(5, scheds[0].MeetingTimeList.Count, "Should have 5 meeeting times"); // Assert the second ScheduleInfo Assert.AreEqual(1, scheds[1].TeacherList.Count, "Should have one teacher"); Assert.AreEqual(5, scheds[1].MeetingTimeList.Count, "Should have 5 meeeting times"); // Assert that the SchoolCourseInfoOverride parsed correctly SchoolCourseInfoOverride cio = sectionInfo.SchoolCourseInfoOverride; Assert.IsNotNull(cio.CourseCredits, "Should have a CourseCreditsOverrides"); // NOTE: This will currently fail every time, due to a bug in // CompareGraphTo AdkObjectParseHelper.runParsingTest(sectionInfo, SifVersion.SIF15r1); }
public void testSectionInfoMappings() { SectionInfo si = new SectionInfo(); Mappings mappings = fCfg.Mappings.GetMappings("Default"); IDictionary map = new Hashtable(); map.Add("STAFF_REFID", "123456789ABCDEF"); StringMapAdaptor sma = new StringMapAdaptor(map); mappings.MapOutbound(sma, si); si = (SectionInfo)AdkObjectParseHelper.WriteParseAndReturn(si, fVersion); // Assert that the object was mapped correctly ScheduleInfoList sil = si.ScheduleInfoList; Assertion.AssertNotNull(sil); ScheduleInfo schedule = sil.ItemAt(0); Assertion.AssertNotNull(schedule); TeacherList tl = schedule.TeacherList; Assertion.AssertNotNull(tl); StaffPersonalRefId refId = tl.ItemAt(0); Assertion.AssertNotNull(refId); Assertion.AssertEquals("123456789ABCDEF", refId.Value); // Now, map the object back to a hashmap and assert it IDictionary restoredData = new Hashtable(); sma = new StringMapAdaptor(restoredData); mappings.MapInbound(si, sma); assertMapsAreEqual(map, restoredData); }
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); }
private bool RunSingleTest( SifVersion parseVersion, SifVersion writeVersion, string fileName, TextWriter output, SchemaValidator sv) { sv.Clear(); if (VERBOSE) { output.Write("Running test on " + fileName + "\r\n"); } // 1) Read the object into memory SifElement se = null; try { se = AdkObjectParseHelper.ParseFile(fileName, parseVersion); } catch (AdkException adke) { // Parsing failed. However, since this unit test is a complete // test of all available objects, just emit the problem and allow // the test to continue (with a notification of false) output .WriteLine("Error parsing file " + fileName + "\r\n - " + adke); output.WriteLine(); return(false); } catch (Exception re) { output.WriteLine("Error parsing file " + fileName + "\r\n - " + re); output.WriteLine(); return(false); } // if (VERBOSE) // { // SifWriter writer = new SifWriter(output); // writer.Write(se,parseVersion); // output.Flush(); // } // Before we can validate with the schema, we need to ensure that the // data object is wrapped in a SIF_Message elements, because the SIF // Schema makes that assumption SifMessagePayload smp = SchemaValidator.MakeSIFMessagePayload(se); String tmpFileName = fileName + "." + writeVersion.ToString() + ".adk"; // 2) Write the message out to a file SchemaValidator.WriteObject(writeVersion, tmpFileName, smp); // 3) Validate the file bool validated = sv.Validate(tmpFileName); // 4) If validation failed, write the object out for tracing purposes if (!validated) { if (VERBOSE) { SifWriter outWriter = new SifWriter(output); outWriter.Write(se, writeVersion); outWriter.Flush(); } output.WriteLine("Errors reading/writing " + fileName); sv.PrintProblems(output); return(false); } // 5) Read the object again into memory try { se = AdkObjectParseHelper.ParseFile(fileName, parseVersion); } catch (AdkException adke) { // Parsing failed. However, since this unit test is a complete // test of all available objects, just emit the problem and allow // the test to continue (with a notification of false) output.WriteLine("Error parsing file " + fileName + ": " + adke.Message); return(false); } catch (Exception re) { output.Write("Error parsing file " + fileName + ": " + re.Message + "\r\n"); return(false); } return(validated); }