public void EndpointQualifierTest() { var q = new EndpointQualifier(ProtocolType.Client, "identifier"); Assert.That(q.Type, Is.EqualTo(ProtocolType.Client)); Assert.That(q.Identifier, Is.EqualTo("identifier")); Assert.That(q.FactoryId, Is.EqualTo(0)); Assert.That(q.ClassId, Is.EqualTo(17)); Assert.That(q, Ish.Equatable( new EndpointQualifier(ProtocolType.Client, "identifier"), new EndpointQualifier(ProtocolType.MemCache, "identifier"), new EndpointQualifier(ProtocolType.Client, "other"))); Assert.That(q.GetHashCode(), Is.Not.Zero); Assert.Throws <ArgumentNullException>(() => q.WriteData(null)); Assert.Throws <ArgumentNullException>(() => q.ReadData(null)); var output = new ObjectDataOutput(1024, null, Endianness.BigEndian); q.WriteData(output); var input = new ObjectDataInput(output.ToByteArray(), null, Endianness.BigEndian); var r = new EndpointQualifier(ProtocolType.Wan, "meh"); r.ReadData(input); Assert.That(q, Is.EqualTo(r)); }
public void DistributedObjectInfoTest() { var x = new DistributedObjectInfo("serviceName", "name"); Console.WriteLine(x); Assert.That(x.ServiceName, Is.EqualTo("serviceName")); Assert.That(x.Name, Is.EqualTo("name")); Assert.That(x, Ish.Equatable( new DistributedObjectInfo("serviceName", "name"), new DistributedObjectInfo("serviceName", "other"), new DistributedObjectInfo("other", "name"))); var hash = x.GetHashCode(); Assert.That(hash, Is.Not.Zero); }
public void MemberInfoTest() { var memberId = Guid.NewGuid(); var address = NetworkAddress.Parse("192.168.33.34:5569"); var version = new MemberVersion(4, 5, 6); var attributes = new Dictionary <string, string> { { "attribute", "value" } }; var x = new MemberInfo(memberId, address, version, true, attributes); Console.WriteLine(x); Assert.That(x.Id, Is.EqualTo(memberId)); Assert.That(x.Uuid, Is.EqualTo(memberId)); Assert.That(x.Address, Is.SameAs(address)); Assert.That(x.Version, Is.SameAs(version)); Assert.That(x.IsLiteMember, Is.True); Assert.That(x.IsLiteMember, Is.True); var a = x.Attributes; Assert.That(a.Count, Is.EqualTo(1)); Assert.That(a["attribute"], Is.EqualTo("value")); Assert.That(x, Ish.Equatable( // weird indeed, but only the ID matters new MemberInfo(memberId, x.Address, x.Version, x.IsLiteMember, attributes), new MemberInfo(Guid.NewGuid(), x.Address, x.Version, x.IsLiteMember, attributes) )); var y = new MemberInfo(address, memberId, attributes, true, version, false, null); var map = new Dictionary <EndpointQualifier, NetworkAddress>(); var z = new MemberInfo(address, memberId, attributes, true, version, true, map); }
public static List <Ish> SelectIshQuery(string qiymat1, string qiymat2, string qiymat3, int count) { List <Ish> list = new List <Ish>(); try { XDocument doc = GetXMLDocument("Data\\Ish.xml"); if (doc == null) { return(null); } XElement elems = doc.Element("IshDocument"); bool t = true; int i = 0; //MessageBox.Show(qiymat3); foreach (XElement elem in elems.Elements()) { t = true; if (qiymat1 != "" && qiymat1 != "12" && elem.Element("ITI").Value != qiymat1) { t = false; } if (t && qiymat2 != "" && qiymat2 != "4" && elem.Element("PKL").Value != qiymat2) { t = false; } if (t && qiymat3 != "" && elem.Element("Nom").Value.ToLower().IndexOf(qiymat3) != 0) { t = false; } uint ii; if (t) { Ish ish = new Ish(); ish.Id = uint.TryParse(elem.Element("Id").Value, out ii) ? ii : 0; ish.Nom = elem.Element("Nom").Value; //ish.Tarkibi = elem.Element("Tarkibi").ToString(); //ish.Izoh = elem.Element("Izoh").ToString(); ish.IshVaqti = ToDuoubleNuqta(elem.Element("IV").Value); ish.IshTuriId = uint.TryParse(elem.Element("ITI").Value, out ii) ? ii : 0; ish.PKL = uint.TryParse(elem.Element("PKL").Value, out ii) ? ii : 0; ish.NomerNorma = elem.Element("NN").Value; ish.KotegoriyaSlojnost = elem.Element("KS").Value; ish.TarifStavka = ToDuoubleNuqta(elem.Element("TS").Value); ish.OlchovBirligi = elem.Element("OB").Value; list.Add(ish); i++; if (i >= count && count > 0) { break; } } } } catch (Exception exc) { MessageBox.Show(exc.ToString()); } return(list); }
public static List <Ish> SelectIshAll(string where, string qiymat) { List <Ish> list = new List <Ish>(); try { XDocument doc = GetXMLDocument("Data\\Ish.xml"); if (doc == null) { return(null); } uint ii; XElement elems = doc.Element("IshDocument"); if (where != null && qiymat != null) { foreach (XElement elem in elems.Elements()) { if (elem.Element(where).Value.ToString() == qiymat) { Ish ish = new Ish(); ish.Id = uint.TryParse(elem.Element("Id").Value, out ii) ? ii : 0; ish.Nom = elem.Element("Nom").Value; ish.Tarkibi = elem.Element("Tarkibi").Value; ish.Izoh = elem.Element("Izoh").Value; ish.IshVaqti = ToDuoubleNuqta(elem.Element("IV").Value); ish.IshTuriId = uint.TryParse(elem.Element("ITI").Value, out ii) ? ii : 0; ish.PKL = uint.TryParse(elem.Element("PKL").Value, out ii) ? ii : 0; ish.NomerNorma = elem.Element("NN").Value; ish.KotegoriyaSlojnost = elem.Element("KS").Value; ish.TarifStavka = ToDuoubleNuqta(elem.Element("TS").Value); ish.OlchovBirligi = elem.Element("OB").Value; list.Add(ish); } } } else { foreach (XElement elem in elems.Elements()) { Ish ish = new Ish(); ish.Id = uint.TryParse(elem.Element("Id").Value, out ii) ? ii : 0; ish.Nom = elem.Element("Nom").Value; ish.Tarkibi = elem.Element("Tarkibi").Value; ish.Izoh = elem.Element("Izoh").Value; ish.IshVaqti = ToDuoubleNuqta(elem.Element("IV").Value); ish.IshTuriId = uint.TryParse(elem.Element("ITI").Value, out ii) ? ii : 0; ish.PKL = uint.TryParse(elem.Element("PKL").Value, out ii) ? ii : 0; ish.NomerNorma = elem.Element("NN").Value; ish.KotegoriyaSlojnost = elem.Element("KS").Value; ish.TarifStavka = ToDuoubleNuqta(elem.Element("TS").Value); ish.OlchovBirligi = elem.Element("OB").Value; list.Add(ish); } } } catch (Exception exc) { MessageBox.Show(exc.ToString()); } return(list); }