本文整理汇总了C#中ReadPreference.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# ReadPreference.GetHashCode方法的具体用法?C# ReadPreference.GetHashCode怎么用?C# ReadPreference.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadPreference
的用法示例。
在下文中一共展示了ReadPreference.GetHashCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetHashCodeIsSameWhenEverythingIsTheSame
public void TestGetHashCodeIsSameWhenEverythingIsTheSame()
{
var tagSets1 = new List<ReplicaSetTagSet>()
{
new ReplicaSetTagSet
{
new ReplicaSetTag("dc", "ny")
}
};
var readPreference1 = new ReadPreference(ReadPreferenceMode.Nearest, tagSets1);
var tagSets2 = new List<ReplicaSetTagSet>()
{
new ReplicaSetTagSet
{
new ReplicaSetTag("dc", "ny")
}
};
var readPreference2 = new ReadPreference(ReadPreferenceMode.Nearest, tagSets2);
Assert.AreEqual(readPreference1.GetHashCode(), readPreference2.GetHashCode());
}
示例2: Equals_should_return_false_when_any_field_is_not_equal
public void Equals_should_return_false_when_any_field_is_not_equal(
[Values("mode", "tagSets")]
string notEqualFieldName)
{
var mode = ReadPreferenceMode.Secondary;
var tagSets = new[] { new TagSet(new[] { new Tag("name", "value1") }) };
var subject1 = new ReadPreference(mode, tagSets);
switch (notEqualFieldName)
{
case "mode": mode = ReadPreferenceMode.SecondaryPreferred; break;
case "tagSets": tagSets = new[] { new TagSet(new[] { new Tag("name", "value2") }) }; break;
default: throw new ArgumentException("notEqualFieldName");
}
var subject2 = new ReadPreference(mode, tagSets);
var result1 = subject1.Equals(subject2);
var result2 = subject1.Equals((object)subject2);
var hashCode1 = subject1.GetHashCode();
var hashCode2 = subject2.GetHashCode();
result1.Should().BeFalse();
result2.Should().BeFalse();
hashCode1.Should().NotBe(hashCode2);
}
示例3: Equals_should_return_true_when_all_fields_are_equal
public void Equals_should_return_true_when_all_fields_are_equal()
{
var mode = ReadPreferenceMode.Secondary;
var tagSets = new[] { new TagSet(new[] { new Tag("name", "value") }) };
var subject1 = new ReadPreference(mode, tagSets);
var subject2 = new ReadPreference(mode, tagSets);
var result1 = subject1.Equals(subject2);
var result2 = subject1.Equals((object)subject2);
var hashCode1 = subject1.GetHashCode();
var hashCode2 = subject2.GetHashCode();
result1.Should().BeTrue();
result2.Should().BeTrue();
hashCode1.Should().Be(hashCode2);
}
示例4: Equals_Act_and_Assert
// private methods
private void Equals_Act_and_Assert(ReadPreference lhs, ReadPreference rhs, bool expectedResult)
{
var result1 = lhs.Equals(rhs);
var result2 = lhs.Equals((object)rhs);
var hashCode1 = lhs.GetHashCode();
var hashCode2 = rhs.GetHashCode();
result1.Should().Be(expectedResult);
result2.Should().Be(expectedResult);
(hashCode1 == hashCode2).Should().Be(expectedResult);
}