Пример #1
0
        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);
        }
Пример #2
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 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 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");
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }