private void TestMf(string name) { Field mf = new Field(name); Assert.AreEqual(IdName.Hash(name), mf.Id); Assert.AreEqual(name, mf.Name); }
private void TestMt(string name) { XType mt = new XType(name); Assert.AreEqual(IdName.Hash(name), mt.Id); Assert.AreEqual(name, mt.Name); }
public void Get_3() { Assert.AreEqual(2, map.Size()); IdName x = map.Get(3); Assert.IsNull(x); Assert.AreEqual(2, map.Size()); }
public void Get_c() { Assert.AreEqual(2, map.Size()); IdName c = map.Get("c"); Check("c", 352988318, c); Assert.AreEqual(3, map.Size()); }
public void Get_d_locked() { Assert.AreEqual(2, map.Size()); map.Lock(); IdName d = map.Get("d"); Assert.IsNull(d); Assert.AreEqual(2, map.Size()); }
public void Get_3_locked() { Assert.AreEqual(2, map.Size()); map.Lock(); IdName x = map.Get(3); Assert.IsNull(x); Assert.AreEqual(2, map.Size()); }
public void Hash() { Assert.AreEqual(5381, IdName.Hash("")); Assert.AreEqual(352988316, IdName.Hash("a")); Assert.AreEqual(1511848646, IdName.Hash("ab")); Assert.AreEqual(669497117, IdName.Hash("abc")); Assert.AreEqual(-1994190713, IdName.Hash("abcd")); Assert.AreEqual(-802680418, IdName.Hash("abcde")); Assert.AreEqual(1266308680, IdName.Hash("abcdef")); Assert.AreEqual(-379372513, IdName.Hash("abcdefg")); Assert.AreEqual(-1416967159, IdName.Hash("abcdefgh")); Assert.AreEqual(53556896, IdName.Hash("abcdefghi")); Assert.AreEqual(-4427318, IdName.Hash("abcdefghij")); }
private void Check(String name, int id, IdName idName) { IdName x = map.Get(id); Assert.IsNotNull(x); Assert.AreSame(idName, x); Assert.AreEqual(id, x.Id); Assert.AreEqual(name, x.Name); x = map.Get(name); Assert.IsNotNull(x); Assert.AreSame(idName, x); Assert.AreEqual(id, x.Id); Assert.AreEqual(name, x.Name); }
/// Override public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj == null) { return(false); } if (this.GetType() != obj.GetType()) { return(false); } IdName other = (IdName)obj; return(id.Equals(other.Id) && name.Equals(other.Name)); }