public void testHashCode() { Name foo1 = new Name("/ndn/foo"); Name foo2 = new Name("/ndn/foo"); Assert.AssertEquals("Hash codes for same Name value are not equal", foo1.GetHashCode(), foo2.GetHashCode()); Name bar1 = new Name("/ndn/bar"); // Strictly speaking, it is possible for a hash collision, but unlikely. Assert.AssertTrue("Hash codes for different Name values are not different", foo1.GetHashCode() != bar1.GetHashCode()); Name bar2 = new Name("/ndn"); int beforeHashCode = bar2.GetHashCode(); bar2.append("bar"); Assert.AssertTrue("Hash code did not change when changing the Name object", beforeHashCode != bar2.GetHashCode()); Assert.AssertEquals( "Hash codes for same Name value after changes are not equal", bar1.GetHashCode(), bar2.GetHashCode()); }