当前位置: 首页>>代码示例>>C#>>正文


C# ReadPreference.GetHashCode方法代码示例

本文整理汇总了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());
        }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:22,代码来源:ReadPreferenceTests.cs

示例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);

        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:25,代码来源:ReadPreferenceTests.cs

示例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);

        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:17,代码来源:ReadPreferenceTests.cs

示例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);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:12,代码来源:ReadPreferenceTests.cs


注:本文中的ReadPreference.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。