本文整理汇总了C#中Identity.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Identity.GetHashCode方法的具体用法?C# Identity.GetHashCode怎么用?C# Identity.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Identity
的用法示例。
在下文中一共展示了Identity.GetHashCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHashCode_EqualsIdentitiesDifferentCasing_ReturnsSameHash
public void GetHashCode_EqualsIdentitiesDifferentCasing_ReturnsSameHash()
{
var identity1 = new Identity()
{
Name = DataUtil.CreateRandomString(10).ToUpper(),
Domain = DataUtil.CreateRandomString(10).ToUpper()
};
var identity2 = new Identity()
{
Name = identity1.Name.ToLower(),
Domain = identity1.Domain.ToLower()
};
Assert.AreEqual(identity1.GetHashCode(), identity2.GetHashCode());
}
示例2: GetHashCode_NotEqualsIdentities_ReturnsDifferentHash
public void GetHashCode_NotEqualsIdentities_ReturnsDifferentHash()
{
var identity1 = new Identity()
{
Name = DataUtil.CreateRandomString(10),
Domain = DataUtil.CreateRandomString(10)
};
var identity2 = new Identity()
{
Name = new string(identity1.Name.Reverse().ToArray()) + DataUtil.CreateRandomString(5),
Domain = new string(identity1.Domain.Reverse().ToArray()) + DataUtil.CreateRandomString(5),
};
Assert.AreNotEqual(identity1.GetHashCode(), identity2.GetHashCode());
}
示例3: GetHashCode_EqualsIdentities_ReturnsSameHash
public void GetHashCode_EqualsIdentities_ReturnsSameHash()
{
var identity1 = new Identity()
{
Name = DataUtil.CreateRandomString(10),
Domain = DataUtil.CreateRandomString(10)
};
var identity2 = new Identity()
{
Name = identity1.Name,
Domain = identity1.Domain
};
Assert.AreEqual(identity1.GetHashCode(), identity2.GetHashCode());
}