/** * Stores the items in the cache that will later be asserted * @param cache */ private void storeAssertedRequests(RequestCache cache) { SIF_QueryObject obj = new SIF_QueryObject(""); SIF_Query query = new SIF_Query(obj); SIF_Request request = new SIF_Request(); request.SIF_Query = query; Query q; TestState ts; fMsgIds = new String[10]; fStateObjects = new String[10]; // Add 10 entries to the cache, interspersed with other entries that are removed for (int i = 0; i < 10; i++) { ts = new TestState(); ts.State = Adk.MakeGuid(); fStateObjects[i] = ts.State; q = new Query(StudentDTD.STUDENTPERSONAL); q.UserData = ts; String phantom1 = Adk.MakeGuid(); String phantom2 = Adk.MakeGuid(); storeRequest(cache, request, q, phantom1, "foo"); fMsgIds[i] = Adk.MakeGuid(); storeRequest(cache, request, q, fMsgIds[i], "Object_" + i.ToString()); storeRequest(cache, request, q, phantom2, "bar"); cache.GetRequestInfo(phantom1, null); cache.GetRequestInfo(phantom2, null); } }
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"); }
/// <summary> /// Gets the default properties for a transport protocol /// </summary> /// <remarks> /// Each transport protocol supported by the ADK is represented by a class /// that implements the Transport interface. Transports are identified by /// a string such as "http" or "https". Like Zones, each Transport instance /// is associated with a set of properties specific to the transport /// protocol. Such properties may include IP address, port, SSL security /// attributes, and so on. The default properties for a given transport /// protocol may be obtained by calling this method. /// </remarks> /// <param name="protocol"></param> /// <returns>The default properties for the specified protocol</returns> /// <exception cref="AdkTransportException">is thrown if the protocol is not supported /// by the ADK</exception> public TransportProperties GetDefaultTransportProperties(String protocol) { // Already initialized? if (fDefaultTransportProps == null) { fDefaultTransportProps = new List <TransportProperties>(); } else { foreach (TransportProperties props in fDefaultTransportProps) { if (props.Protocol.Equals(protocol)) { return(props); } } } // Didn't find the transport properties above. Create a new one and return it TransportPlugin tp = Adk.GetTransportProtocol(protocol); if (tp == null) { throw new AdkTransportException("The requested transport protocol: '" + protocol + "' is not supported by this instance of the ADK", null); } TransportProperties properties = tp.CreateProperties(); properties.Defaults(null); fDefaultTransportProps.Add(properties); return(properties); }
public void setUp() { Adk.Initialize(); fAgent = new TestAgent(); fAgent.Initialize(); }
public void testStudentSnapshot15r1() { StringMapAdaptor sma = createStudentSnapshotFields(); StudentSnapshot ss = new StudentSnapshot(); ss.StudentPersonalRefId = Adk.MakeGuid(); ss.SnapDate = DateTime.Now; Mappings m = fCfg.Mappings.GetMappings("Default").Select(null, null, null); m .MapOutbound(sma, ss, new DefaultValueBuilder(sma), SifVersion.SIF15r1); Console.WriteLine(ss.ToXml()); int?onTimeGradYear = ss.OnTimeGraduationYear; Assertion.Assert("onTimeGraduationYear is null", onTimeGradYear.HasValue); Assertion.AssertEquals("OnTimeGraduationYear", 2000, onTimeGradYear.Value); SchemaValidator sv = USSchemaValidator.NewInstance(SifVersion.SIF15r1); // 3) Validate the file bool validated = sv.Validate(ss, SifVersion.SIF15r1); // 4) If validation failed, write the object out for tracing purposes if (!validated) { sv.PrintProblems(Console.Out); Assertion.Fail("Schema Validation Failed:"); } }
public ITransport GetTransport(String protocol) { if (protocol == null) { throw new ArgumentException("Protocol cannot be null"); } protocol = protocol.ToLower(); foreach (ITransport trans in fTransports) { if (trans.Protocol.Equals(protocol)) { return(trans); } } // No transport has been created for this protocol yet. Create // new one using the TransportPlugin TransportPlugin tp = Adk.GetTransportProtocol(protocol); TransportProperties defs = GetDefaultTransportProperties(protocol); ITransport transport = tp.NewInstance(defs); fTransports.Add(transport); return(transport); }
public virtual void setUp() { Adk.Initialize(); fCfg = new AgentConfig(); fCfg.Read("..\\..\\Library\\Tools\\Mapping\\SIF1.5.agent.cfg", false); }
public void testAssertSIFGUIDFormat() { String refId = Adk.MakeGuid(); Console.WriteLine(refId); assertRefId(refId); }
public virtual void StartTests() { if (!Adk.Initialized) { Adk.Initialize(SifVersion.LATEST, SdoLibraryType.All); } }
private static void Main(string[] args) { try { Adk.Debug = AdkDebugFlags.Moderate; Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_AU, (int)SdoLibraryType.All); Chameleon agent; agent = new Chameleon(); // Start agent... agent.StartAgent(args); Console.WriteLine("Agent is running (Press Ctrl-C to stop)"); sWaitMutex = new AdkConsoleWait(); sWaitMutex.WaitForExit(); // Always shutdown the agent on exit agent.Shutdown(ProvisioningFlags.None); } catch (Exception e) { Console.WriteLine(e); } }
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 static void Main(string[] args) { try { // Pre-parse the command line before initializing the ADK Adk.Debug = AdkDebugFlags.Moderate; AdkExamples.parseCL(null, args); // Initialize the ADK. Note even though this example uses raw XML, // it is still required that the appropriate SDO libraries be loaded Adk.Initialize(AdkExamples.Version, SIFVariant.SIF_US, (int)SdoLibraryType.Student); // Start agent... MappingsDemo agent; agent = new MappingsDemo(); agent.startAgent(args); // Wait for Ctrl-C to be pressed Console.WriteLine(); Console.WriteLine("Agent is running (Press Ctrl-C to stop)"); Console.WriteLine(); // Install a shutdown hook to cleanup when Ctrl+C is pressed new AdkConsoleWait().WaitForExit(); agent.Shutdown (AdkExamples.Unreg ? ProvisioningFlags.Unregister : ProvisioningFlags.None); } catch (Exception e) { Console.WriteLine(e); } }
public static int Main(string[] args) { SimpleProvider agent = null; try { if (args.Length < 2) { Console.WriteLine("Usage: SimpleProvider /zone zone /url url [/events] [options]"); Console.WriteLine(" /zone zone The name of the zone"); Console.WriteLine(" /url url The zone URL"); Console.WriteLine(" /events Periodically send change events"); AdkExamples.printHelp(); return(0); } Console.ForegroundColor = ConsoleColor.Green; // Pre-parse the command-line before initializing the ADK Adk.Debug = AdkDebugFlags.None; AdkExamples.parseCL(null, args); // Initialize the ADK with the specified version, loading only the Student SDO package Adk.Initialize(SifVersion.SIF23, SIFVariant.SIF_UK, (int)SdoLibraryType.All); // Start the agent... agent = new SimpleProvider(); // Call StartAgent. This method does not return until the agent shuts down agent.startAgent(args); // Wait for Ctrl-C to be pressed Console.WriteLine("Agent is running (Press Ctrl-C to stop)"); new AdkConsoleWait().WaitForExit(); } catch (Exception e) { Console.WriteLine(e); } finally { if (agent != null && agent.Initialized) { // Always shutdown the agent on exit try { agent.Shutdown (AdkExamples.Unreg ? ProvisioningFlags.Unregister : ProvisioningFlags.None); } catch (AdkException adkEx) { Console.WriteLine(adkEx); } } } return(0); }
public virtual void setUp() { if (!Adk.Initialized) { Adk.Initialize(SifVersion.LATEST, SIFVariant.SIF_US, (int)SdoLibraryType.All); } Adk.SifVersion = SifVersion.LATEST; }
public void testConditionWithNullValue() { StudentPersonal sp = new StudentPersonal(Adk.MakeGuid(), new Name(NameType.BIRTH, "E", "Sally")); Query q = new Query(StudentDTD.STUDENTPERSONAL); q.AddCondition(CommonDTD.NAME_LASTNAME, ComparisonOperators.GT, null); Assert.IsFalse(q.Evaluate(sp)); }
private static StudentPersonal CreateStudent( String id, String lastName, String firstName, String street, String city, String state, CountryCode country, String post, String phone, Sex gender, YearLevelCode grade, String birthDateyyyyMMdd) { StudentPersonal student = new StudentPersonal(); ; student.RefId = Adk.MakeGuid(); student.LocalId = id; PersonInfo stupersonal = new PersonInfo(); student.PersonInfo = stupersonal; // Set the Name Name name = new Name(NameType.LEGAL); name.FamilyName = lastName; name.GivenName = firstName; stupersonal.Name = name; Address addr = new Address(); addr.SetType(AddressType.C0765_PHYSICAL_LOCATION); addr.SetStreet(street); addr.City = city; addr.StateProvince = state; addr.PostalCode = post; addr.Country = country.ToString(); stupersonal.AddressList = new AddressList(addr); stupersonal.PhoneNumberList = new PhoneNumberList(new PhoneNumber(PhoneNumberType.PRIMARY, phone)); Demographics dem = new Demographics(); dem.SetSex(gender); dem.BirthDate = DateTime.ParseExact (birthDateyyyyMMdd, "yyyyMMdd", CultureInfo.InvariantCulture.DateTimeFormat); stupersonal.Demographics = dem; return(student); }
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 TestStableSortInGetContent() { if (!Adk.Initialized) { Adk.Initialize(); } SIF_Register sr = new SIF_Register(); sr.SIF_Icon = "test.ico"; // Create the original list of SIF_Version strings string[] list = new string[5]; list[0] = "1.1"; list[1] = "2.*"; list[2] = "2.0r1"; list[3] = "2.5"; list[4] = "1.0r1"; for (int a = 0; a < 5; a++) { sr.AddSIF_Version(new SIF_Version(list[a])); } sr.SIF_Name = "AgentName"; sr.SIF_Mode = "Push"; IList <Element> elements = Adk.Dtd.GetFormatter(SifVersion.SIF11).GetContent(sr, SifVersion.SIF11); // We should have gotten back a list of elements like this: // SIF_Name // 5 SIF_Version elements // SIF_Mode // SIF_Icon (only if the version is 2.0 or greater) Assert.AreEqual("AgentName", elements[0].TextValue); // Assert that the SIF_Version elements returned are still in the order they went in for (int a = 0; a < 5; a++) { Assert.AreEqual(list[a], elements[a + 1].TextValue); } Assert.AreEqual("Push", elements[6].TextValue); // NOTE: SIF_Icon is not present in SIF 1.1 elements = Adk.Dtd.GetFormatter(SifVersion.SIF21).GetContent(sr, SifVersion.SIF21); Assert.AreEqual("AgentName", elements[0].TextValue); // Assert that the SIF_Version elements returned are still in the order they went in for (int a = 0; a < 5; a++) { Assert.AreEqual(list[a], elements[a + 1].TextValue); } Assert.AreEqual("Push", elements[6].TextValue); Assert.AreEqual("test.ico", elements[7].TextValue); }
public void ADKIntegrityTest() { SifVersion[] versions = Adk.SupportedSIFVersions; foreach (SifVersion version in versions) { Assert.IsTrue(Adk.IsSIFVersionSupported(version), version.ToString()); Assert.AreEqual(version, SifVersion.Parse(version.ToString()), version.ToString()); } }
public void setUp() { if (!Adk.Initialized) { Adk.Initialize( ); } Adk.SifVersion = fVersion; fCfg = new AgentConfig(); fCfg.Read("..\\..\\Library\\Tools\\Mapping\\SASI2.0.cfg", false); }
public void SetUp() { Adk.Initialize(); /* * f64BitKey = new byte[8]; * RNGCryptoServiceProvider.Create().GetBytes( f64BitKey ); */ f64BitKey = Convert.FromBase64String("dW7SKzwdn0Q="); f128BitKey = Convert.FromBase64String("TcdilmUZ6qvbmegl2it2pA=="); f192BitKey = Convert.FromBase64String("mECbXMo+fOMWRwam7tyUEE59jbO9O0Z4"); StringBuilder builder = new StringBuilder(); builder.Append("Created Unique 64-bit Encryption Key: "); foreach (byte b in f64BitKey) { builder.AppendFormat("0x{0:X}", b); builder.Append(new char[] { ',', ' ' }); } builder.Append("\r\nBase 64 Value: "); builder.Append(Convert.ToBase64String(f64BitKey)); Console.WriteLine(builder.ToString()); /* * f128BitKey = new byte[16]; * RNGCryptoServiceProvider.Create().GetBytes( f128BitKey ); */ builder = new StringBuilder(); builder.Append("Created Unique 128-bit Encryption Key: "); foreach (byte b in f128BitKey) { builder.AppendFormat("0x{0:X}", b); builder.Append(new char[] { ',', ' ' }); } builder.Append("\r\nBase 64 Value: "); builder.Append(Convert.ToBase64String(f128BitKey)); Console.WriteLine(builder.ToString()); builder = new StringBuilder(); builder.Append("Created Unique 192-bit Encryption Key: "); foreach (byte b in f192BitKey) { builder.AppendFormat("0x{0:X}", b); builder.Append(new char[] { ',', ' ' }); } builder.Append("\r\nBase 64 Value: "); builder.Append(Convert.ToBase64String(f192BitKey)); Console.WriteLine(builder.ToString()); }
private SifDataObject createPerson(string id, string lastName, string firstName, string number, string street, string locality, string town, string post, string phone, string gender, string grade, EthnicityCodes ethnicity, string birthDateyyyyMMdd) { SifDataObject person = createPersonObject(id); person.SetElementOrAttribute("@RefId", Adk.MakeGuid()); Name name = new Name(NameType.CURRENT_LEGAL, firstName, lastName); PersonalInformation personal = new PersonalInformation(name); person.AddChild(CommonDTD.PERSONALINFORMATION, personal); AddressableObjectName aon = new AddressableObjectName(); aon.StartNumber = number; Address address = new Address(AddressType.CURRENT, aon); address.Street = street; address.Locality = locality; address.Town = town; address.PostCode = post; address.SetCountry(CountryCode.GBR); personal.Address = address; personal.PhoneNumber = new PhoneNumber(PhoneType.HOME, phone); Demographics dem = new Demographics(); dem.SetEthnicityList(new Ethnicity(ethnicity)); dem.SetGender(Gender.Wrap(gender)); try { dem.BirthDate = SifDate.ParseSifDateString(birthDateyyyyMMdd, SifVersion.SIF15r1); } catch (Exception pex) { Console.WriteLine(pex); } personal.Demographics = dem; return(person); }
public void Setup() { Adk.Initialize(); TransportPlugin tp = new InMemoryTransportPlugin(); Adk.InstallTransport(tp); fAgent = new TestAgent(); fAgent.Initialize(); fAgent.Properties.TransportProtocol = tp.Protocol; fZone = (TestZoneImpl)fAgent.ZoneFactory.GetInstance("test", "http://test"); } //end method Setup
public void testSifResponseSenderMultiplePackets() { MessageDispatcher testDispatcher = new MessageDispatcher(Zone); Zone.Properties.OneObjectPerResponse = true; Zone.SetDispatcher(testDispatcher); Zone.Connect(ProvisioningFlags.None); InMemoryProtocolHandler testProto = (InMemoryProtocolHandler)Zone.ProtocolHandler; testProto.clear(); // Send a single SIF_Response with a small Authentication object String SifRequestMsgId = Adk.MakeGuid(); String sourceId = "TEST_SOURCEID"; SifVersion testVersion = SifVersion.LATEST; int maxBufferSize = int.MaxValue; IElementDef[] testRestrictions = new IElementDef[] { InfrastructureDTD.AUTHENTICATION_REFID }; SifResponseSender srs = new SifResponseSender(); srs.Open(Zone, SifRequestMsgId, sourceId, testVersion, maxBufferSize, testRestrictions); srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL)); srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL)); srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL)); srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL)); srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL)); srs.Close(); for (int x = 0; x < 5; x++) { // Retrieve the SIF_Response message off the protocol handler and asssert the results SIF_Response response = (SIF_Response)testProto.readMsg(); Assert.AreEqual(SifRequestMsgId, response.SIF_RequestMsgId); Assert.AreEqual(x + 1, response.SIF_PacketNumber.Value); if (x == 4) { Assert.AreEqual("No", response.SIF_MorePackets); } else { Assert.AreEqual("Yes", response.SIF_MorePackets); } SIF_Header header = response.SIF_Header; Assert.AreEqual(sourceId, header.SIF_DestinationId); SifElement responseObject = response.SIF_ObjectData.GetChildList()[0]; Assert.IsNotNull(responseObject); } }
public void testSetPacketNumberAndMorePackets() { MessageDispatcher testDispatcher = new MessageDispatcher(this.Zone); this.Zone.SetDispatcher(testDispatcher); this.Zone.Connect(ProvisioningFlags.None); InMemoryProtocolHandler testProto = (InMemoryProtocolHandler)this.Zone.ProtocolHandler; testProto.clear(); // Send a single SIF_Response with a small Authentication object String SifRequestMsgId = Adk.MakeGuid(); String sourceId = "TEST_SOURCEID"; SifVersion testVersion = SifVersion.LATEST; int maxBufferSize = int.MaxValue; int packetNumber = 999; YesNo morePacketsValue = YesNo.YES; IElementDef[] testRestrictions = new IElementDef[] { InfrastructureDTD.AUTHENTICATION_REFID }; SifResponseSender srs = new SifResponseSender(); srs.Open(this.Zone, SifRequestMsgId, sourceId, testVersion, maxBufferSize, testRestrictions); srs.SIF_PacketNumber = packetNumber; srs.SIF_MorePackets = morePacketsValue; // Assert the values of the properties set before writing Assert.AreEqual(packetNumber, srs.SIF_PacketNumber); Assert.AreEqual(morePacketsValue, srs.SIF_MorePackets); srs.Write(new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.EMPLOYEEPERSONAL)); srs.Close(); // Assert the values of the properties set after writing Assert.AreEqual(packetNumber, srs.SIF_PacketNumber); Assert.AreEqual(morePacketsValue, srs.SIF_MorePackets); // Retrieve the SIF_Response message off the protocol handler and asssert the results SIF_Response response = (SIF_Response)testProto.readMsg(); Assert.AreEqual(SifRequestMsgId, response.SIF_RequestMsgId); Assert.AreEqual(packetNumber, response.SIF_PacketNumber.Value); Assert.AreEqual(morePacketsValue.ToString(), response.SIF_MorePackets); SIF_Header header = response.SIF_Header; Assert.AreEqual(sourceId, header.SIF_DestinationId); SifElement responseObject = response.SIF_ObjectData.GetChildList()[0]; Assert.IsNotNull(responseObject); }
/// <summary> /// Run the agent as an application /// </summary> /// <example> /// Pull mode ///Debug Command line arguments: /zone test /url http://127.0.0.1:7080/test /pull /events true</example> /// <example> Push mode /// /zone test /url http://127.0.0.1:7080/test /push /port 10000 /events true</example> /// <param name="args"></param> public static void Main(String[] args) { SimpleProvider agent = null; try { if (args.Length < 2) { Console.WriteLine ("Usage: SimpleSubscriber /zone zone /url url [/full] [options]"); AdkExamples.printHelp(); return; } // Pre-parse the command-line before initializing the Adk Adk.Debug = AdkDebugFlags.None; AdkExamples.parseCL(null, args); // Initialize the Adk with the specified version, loading only the learner SDO package Adk.Initialize(AdkExamples.Version, SIFVariant.SIF_AU, (int)SdoLibraryType.Student); // Start the agent... agent = new SimpleProvider(); // Call StartAgent. This method does not return until the agent shuts down agent.StartAgent(args); // Wait for Ctrl-C to be pressed Console.WriteLine("Agent is running (Press Ctrl-C to stop)"); new AdkConsoleWait().WaitForExit(); } catch (Exception e) { Console.WriteLine(e); } finally { if (agent != null && agent.Initialized) { // Always shutdown the agent on exit try { agent.Shutdown (AdkExamples.Unreg ? ProvisioningFlags.Unprovide : ProvisioningFlags.None); } catch (AdkException adkEx) { Console.WriteLine(adkEx); } } } }
private Authentication CreateAuthentication() { AuthenticationInfo inf = new AuthenticationInfo(new AuthSystem(AuthSystemType.APPLICATION, "Sample SIF Application")); inf.DistinguishedName = "cn=Example User, cn=Users, dc=sifinfo, dc=org"; inf.Username = "******"; Authentication auth = new Authentication(Adk.MakeGuid(), Adk.MakeGuid(), AuthSifRefIdType.STAFFPERSONAL); auth.AuthenticationInfo = inf; return(auth); }
public static StudentPersonal makeStudentPersonal(String localId, NameType nameType, String firstName, String lastName) { StudentPersonal s = new StudentPersonal(); s.RefId = Adk.MakeGuid(); s.LocalId = localId; Name name = new Name(nameType, lastName, firstName); s.Name = name; return(s); }
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"); }
private static StudentPersonal CreateStudent( String id, String lastName, String firstName, String street, String city, StatePrCode state, CountryCode country, String post, String phone, Gender gender, GradeLevelCode grade, RaceType race, String birthDateyyyyMMdd) { StudentPersonal student = new StudentPersonal(); ; student.RefId = Adk.MakeGuid(); student.LocalId = id; // Set the Name Name name = new Name(NameType.LEGAL, firstName, lastName); student.Name = name; Address addr = new Address(); addr.SetType(AddressType.C0369_PERMANENT); addr.SetStreet(street); addr.City = city; addr.SetStateProvince(state); addr.PostalCode = post; addr.SetCountry(country); student.AddressList = new StudentAddressList(PickupOrDropoff.NA, "NA", addr); student.PhoneNumberList = new PhoneNumberList(new PhoneNumber(PhoneNumberType.PRIMARY, phone)); Demographics dem = new Demographics(); dem.RaceList = new RaceList(new Race("", race)); dem.SetGender(gender); dem.BirthDate = DateTime.ParseExact (birthDateyyyyMMdd, "yyyyMMdd", CultureInfo.InvariantCulture.DateTimeFormat); student.Demographics = dem; return(student); }