本文整理汇总了C#中ReadPreference.With方法的典型用法代码示例。如果您正苦于以下问题:C# ReadPreference.With方法的具体用法?C# ReadPreference.With怎么用?C# ReadPreference.With使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadPreference
的用法示例。
在下文中一共展示了ReadPreference.With方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: With_tagSets_should_return_expected_result
public void With_tagSets_should_return_expected_result()
{
var tagSets1 = new[] { new TagSet(new[] { new Tag("name", "value1") }) };
var tagSets2 = new[] { new TagSet(new[] { new Tag("name", "value2") }) };
var subject = new ReadPreference(ReadPreferenceMode.Secondary, tagSets1);
var result = subject.With(tagSets: tagSets2);
result.ReadPreferenceMode.Should().Be(subject.ReadPreferenceMode);
result.TagSets.Should().Equal(tagSets2);
}
示例2: With_mode_should_return_expected_result
public void With_mode_should_return_expected_result()
{
var mode1 = ReadPreferenceMode.Secondary;
var mode2 = ReadPreferenceMode.SecondaryPreferred;
var subject = new ReadPreference(mode1);
var result = subject.With(mode: mode2);
result.ReadPreferenceMode.Should().Be(mode2);
result.TagSets.Should().Equal(subject.TagSets);
}
示例3: With_mode_should_return_expected_result
public void With_mode_should_return_expected_result(
[Values(ReadPreferenceMode.Primary, ReadPreferenceMode.Secondary)]
ReadPreferenceMode originalMode,
[Values(ReadPreferenceMode.Primary, ReadPreferenceMode.Secondary)]
ReadPreferenceMode mode)
{
var subject = new ReadPreference(originalMode);
var result = subject.With(mode);
result.ReadPreferenceMode.Should().Be(mode);
result.With(originalMode).Should().Be(subject);
}
示例4: With_tagSets_should_return_expected_result
public void With_tagSets_should_return_expected_result(
[Values("a", "b")]
string originalTagValue,
[Values("a", "b")]
string tagValue)
{
var originalTagSets = new[] { new TagSet(new[] { new Tag("x", originalTagValue) }) };
var tagSets = new[] { new TagSet(new[] { new Tag("x", tagValue) }) };
var subject = new ReadPreference(ReadPreferenceMode.Secondary, tagSets: originalTagSets);
var result = subject.With(tagSets);
result.TagSets.Should().Equal(tagSets);
result.With(originalTagSets).Should().Be(subject);
}
示例5: With_maxStaleness_should_return_expected_result
public void With_maxStaleness_should_return_expected_result(
[Values(1, 2)]
int originalSeconds,
[Values(1, 2)]
int seconds)
{
var originalMaxStaleness = TimeSpan.FromSeconds(originalSeconds);
var maxStaleness = TimeSpan.FromSeconds(seconds);
var subject = new ReadPreference(ReadPreferenceMode.Secondary, maxStaleness: originalMaxStaleness);
var result = subject.With(maxStaleness);
result.MaxStaleness.Should().Be(maxStaleness);
result.With(originalMaxStaleness).Should().Be(subject);
}