本文整理汇总了C#中MockHeaders.TryGetValues方法的典型用法代码示例。如果您正苦于以下问题:C# MockHeaders.TryGetValues方法的具体用法?C# MockHeaders.TryGetValues怎么用?C# MockHeaders.TryGetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockHeaders
的用法示例。
在下文中一共展示了MockHeaders.TryGetValues方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetValues_GetValuesForExistingHeader_ReturnsTrueAndListOfValues
public void TryGetValues_GetValuesForExistingHeader_ReturnsTrueAndListOfValues()
{
MockHeaders headers = new MockHeaders();
headers.Add(knownHeader, rawPrefix + "1");
headers.TryAddWithoutValidation(knownHeader, rawPrefix + "2");
headers.TryAddWithoutValidation(knownHeader, string.Empty);
// Only 1 value should get parsed (call to Add() with known header value).
Assert.Equal(1, headers.Parser.TryParseValueCallCount);
IEnumerable<string> values = null;
Assert.True(headers.TryGetValues(knownHeader, out values));
Assert.NotNull(values);
// TryGetValues() should trigger parsing of values added with TryAddWithoutValidation()
Assert.Equal(3, headers.Parser.TryParseValueCallCount);
Assert.Equal(2, values.Count());
// Check returned values
Assert.Equal(parsedPrefix + "1", values.ElementAt(0));
Assert.Equal(parsedPrefix + "2", values.ElementAt(1));
}
示例2: TryGetValues_GetValuesFromUninitializedHeaderStore_ReturnsFalse
public void TryGetValues_GetValuesFromUninitializedHeaderStore_ReturnsFalse()
{
MockHeaders headers = new MockHeaders();
IEnumerable<string> values = null;
// Get header values from uninitialized store (store collection is null)
Assert.False(headers.TryGetValues("doesntexist", out values));
Assert.Equal(0, headers.Count());
}
示例3: TryGetValues_GetValuesForNonExistingHeader_ReturnsFalse
public void TryGetValues_GetValuesForNonExistingHeader_ReturnsFalse()
{
MockHeaders headers = new MockHeaders();
headers.Add("custom1", "customValue1");
IEnumerable<string> values = null;
// Get header values from uninitialized store (store collection is null)
Assert.False(headers.TryGetValues("doesntexist", out values));
Assert.Equal(1, headers.Count());
}
示例4: TryGetValues_UseNullHeader_False
public void TryGetValues_UseNullHeader_False()
{
MockHeaders headers = new MockHeaders();
IEnumerable<string> values = null;
Assert.False(headers.TryGetValues(null, out values));
}