本文整理汇总了C#中ReadPreference.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ReadPreference.ToString方法的具体用法?C# ReadPreference.ToString怎么用?C# ReadPreference.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadPreference
的用法示例。
在下文中一共展示了ReadPreference.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString_should_return_expected_result_when_tagSets_is_set
public void ToString_should_return_expected_result_when_tagSets_is_set(int[] tagSetSizes, string expectedTagSetsString)
{
var tagSets = new List<TagSet>();
foreach (var size in tagSetSizes)
{
var tags = new List<Tag>();
for (var i = 0; i < size; i++)
{
var name = new string((char)('x' + i), 1);
var value = new string((char)('a' + i), 1);
var tag = new Tag(name, value);
tags.Add(tag);
}
var tagSet = new TagSet(tags);
tagSets.Add(tagSet);
}
var subject = new ReadPreference(ReadPreferenceMode.Secondary, tagSets: tagSets);
var result = subject.ToString();
result.Should().Be($"{{ Mode : Secondary, TagSets : {expectedTagSetsString} }}");
}
示例2: ToString_should_return_expected_result_when_maxStaleness_is_set
public void ToString_should_return_expected_result_when_maxStaleness_is_set(
[Values(1, 2)]
int seconds)
{
var maxStaleness = TimeSpan.FromSeconds(seconds);
var subject = new ReadPreference(ReadPreferenceMode.Secondary, maxStaleness: maxStaleness );
var result = subject.ToString();
result.Should().Be($"{{ Mode : Secondary, MaxStaleness : {seconds}s }}");
}
示例3: ToString_should_return_expected_result
public void ToString_should_return_expected_result(
[Values(ReadPreferenceMode.Primary, ReadPreferenceMode.Secondary)]
ReadPreferenceMode mode)
{
var subject = new ReadPreference(mode);
var result = subject.ToString();
result.Should().Be($"{{ Mode : {mode} }}");
}