public void Test_Indexer() { NonChild nc = new NonChild(); GetOpt go = new GetOpt(nc); go["test"] = "foo"; Assert.AreEqual("foo", nc.test); }
public void Test_NonChild() { NonChild nc = new NonChild(); GetOpt go = new GetOpt(nc); go.Process(new string[] {"-test", "foo"}); Assert.AreEqual("foo", nc.test); }
public Class1(string[] args) { JabberClient jc = new JabberClient(); jc.OnReadText += new bedrock.TextHandler(jc_OnReadText); jc.OnWriteText += new bedrock.TextHandler(jc_OnWriteText); jc.OnError +=new bedrock.ExceptionHandler(jc_OnError); jc.OnStreamError += new jabber.protocol.ProtocolHandler(jc_OnStreamError); jc.AutoReconnect = 3f; GetOpt go = new GetOpt(this); try { go.Process(args); } catch (ArgumentException) { go.UsageExit(); } if (untrustedOK) jc.OnInvalidCertificate += new System.Net.Security.RemoteCertificateValidationCallback(jc_OnInvalidCertificate); JID j = new JID(jid); jc.User = j.User; jc.Server = j.Server; jc.NetworkHost = networkHost; jc.Port = port; jc.Resource = "Jabber.Net Console Client"; jc.Password = pass; jc.AutoStartTLS = TLS; jc.AutoPresence = initialPresence; if (certificateFile != null) { jc.SetCertificateFile(certificateFile, certificatePass); Console.WriteLine(jc.LocalCertificate.ToString(true)); } if (boshURL != null) { jc[Options.POLL_URL] = boshURL; jc[Options.CONNECTION_TYPE] = ConnectionType.HTTP_Binding; } if (register) { jc.AutoLogin = false; jc.OnLoginRequired += new bedrock.ObjectHandler(jc_OnLoginRequired); jc.OnRegisterInfo += new RegisterInfoHandler(this.jc_OnRegisterInfo); jc.OnRegistered += new IQHandler(jc_OnRegistered); } CapsManager cm = new CapsManager(); cm.Stream = jc; cm.Node = "http://cursive.net/clients/ConsoleClient"; Console.WriteLine("Connecting"); jc.Connect(); Console.WriteLine("Connected"); string line; while ((line = Console.ReadLine()) != null) { if (line == "/clear") { // Hm.... I wonder if this works on windows. Console.Write("\x1b[H\x1b[2J"); continue; } if ((line == "/q") || (line == "/quit")) { jc.Close(); break; } if (line.Trim() == "") { continue; } try { if (line == "</stream:stream>") { jc.Write(line); } else { // TODO: deal with stanzas that span lines... keep // parsing until we have a full "doc". XmlDocument doc = new XmlDocument(); doc.LoadXml(line); XmlElement elem = doc.DocumentElement; if (elem != null) jc.Write(elem); } } catch (XmlException ex) { Console.WriteLine("Invalid XML: " + ex.Message); } } }