本文整理汇总了C#中Address.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Address.GetHashCode方法的具体用法?C# Address.GetHashCode怎么用?C# Address.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address.GetHashCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HashCode_ignores_machine_name
public void HashCode_ignores_machine_name()
{
Address.IgnoreMachineName();
var address1 = new Address("MyEndpoint", "Server1");
var address2 = new Address("MyEndpoint", "Server2");
Assert.AreEqual(address1.GetHashCode(), address2.GetHashCode());
}
示例2: Value_Objects_Should_Be_Same_If_Contains_Same_Data
public void Value_Objects_Should_Be_Same_If_Contains_Same_Data()
{
var address1 = new Address(new Guid("21C67A65-ED5A-4512-AA29-66308FAAB5AF"), "Baris Manco Street", 42);
var address2 = new Address(new Guid("21C67A65-ED5A-4512-AA29-66308FAAB5AF"), "Baris Manco Street", 42);
Assert.Equal(address1, address2);
Assert.Equal(address1.GetHashCode(), address2.GetHashCode());
Assert.True(address1 == address2);
Assert.False(address1 != address2);
}
示例3: DiferentDataInDiferentPropertiesProduceDiferentHashCodeTest
public void DiferentDataInDiferentPropertiesProduceDiferentHashCodeTest()
{
//Arrange
Address address1 = new Address("streetLine1", "streetLine2", null, null);
Address address2 = new Address("streetLine2", "streetLine1", null, null);
//Act
int address1HashCode = address1.GetHashCode();
int address2HashCode = address2.GetHashCode();
//Assert
Assert.AreNotEqual(address1HashCode, address2HashCode);
}
示例4: AddressEquality
public void AddressEquality()
{
Dictionary<string, object> address = new Dictionary<string, object> { { "Existence", "Exists" }, { "Published", false } };
var ii0 = new Address(typeof(HeaderContent), "abc&def");
var ii1 = new Address(typeof(HeaderContent), "abc&def");
var ii2 = new Address(typeof(RestaurantContent), "abc&def");
var ii3 = new Address(typeof(HeaderContent), "abc");
Assert.IsTrue(ii0.Equals(ii1), ".Equals true");
Assert.IsTrue(ii0 == ii1, "== true");
Assert.IsFalse(ii0.Equals(ii2), ".Equals false by type");
Assert.IsFalse(ii0 == ii2, "== false by different val");
Assert.IsFalse(ii1.Equals(ii3), ".Equals false by missing key");
Assert.IsFalse(ii1 == ii3, "== false by missing key");
Assert.IsFalse(ii0.GetHashCode() == ii2.GetHashCode(), "hash code by type");
Assert.IsFalse(ii1.GetHashCode() == ii3.GetHashCode(), "hash code by missing key");
}
示例5: SameDataSameHashCodeTest
public void SameDataSameHashCodeTest()
{
//Arrange
Address address1 = new Address("streetLine1", "streetLine2", null, null);
Address address2 = new Address("streetLine1", "streetLine2", null, null);
//Act
int address1HashCode = address1.GetHashCode();
int address2HashCode = address2.GetHashCode();
//Assert
Assert.AreEqual(address1HashCode, address2HashCode);
}
示例6: SameDataInDiferentPropertiesProduceDiferentHashCodeTest
public void SameDataInDiferentPropertiesProduceDiferentHashCodeTest()
{
//Arrange
var address1 = new Address("streetLine1", null, null, "streetLine1");
var address2 = new Address(null, "streetLine1", "streetLine1", null);
//Act
var address1HashCode = address1.GetHashCode();
var address2HashCode = address2.GetHashCode();
//Assert
Assert.AreNotEqual(address1HashCode, address2HashCode);
}
示例7: Ensure_that_hash_code_can_be_generated
public void Ensure_that_hash_code_can_be_generated()
{
var address = new Address("street", "unit", "city", "nV", "01134");
Assert.AreEqual(-2039642170, address.GetHashCode());
}