本文整理汇总了C#中MockHeaders.GetParsedValues方法的典型用法代码示例。如果您正苦于以下问题:C# MockHeaders.GetParsedValues方法的具体用法?C# MockHeaders.GetParsedValues怎么用?C# MockHeaders.GetParsedValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockHeaders
的用法示例。
在下文中一共展示了MockHeaders.GetParsedValues方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetParsedValues_AddInvalidValueToHeader_HeaderGetsRemovedAndNullReturned
public void GetParsedValues_AddInvalidValueToHeader_HeaderGetsRemovedAndNullReturned()
{
MockHeaders headers = new MockHeaders();
headers.TryAddWithoutValidation(knownHeader, invalidHeaderValue + "\r\ninvalid");
Assert.Equal(0, headers.Parser.TryParseValueCallCount);
object storeValue = headers.GetParsedValues(knownHeader);
Assert.Null(storeValue);
Assert.False(headers.Contains(knownHeader));
}
示例2: GetParsedValues_GetParsedValuesForKnownHeaderWithInvalidNewlineChars_ReturnsNull
public void GetParsedValues_GetParsedValuesForKnownHeaderWithInvalidNewlineChars_ReturnsNull()
{
MockHeaders headers = new MockHeaders();
// Add header value with invalid newline chars.
headers.TryAddWithoutValidation(knownHeader, invalidHeaderValue + "\r\ninvalid");
Assert.Equal(0, headers.Parser.TryParseValueCallCount);
Assert.Null(headers.GetParsedValues(knownHeader));
Assert.Equal(0, headers.Count());
Assert.Equal(1, headers.Parser.TryParseValueCallCount);
}
示例3: GetParsedValues_GetValuesForExistingHeaderWithInvalidValues_ReturnsOnlyParsedValues
public void GetParsedValues_GetValuesForExistingHeaderWithInvalidValues_ReturnsOnlyParsedValues()
{
MockHeaders headers = new MockHeaders();
headers.Add(knownHeader, rawPrefix);
// Here we add an invalid value. GetValues<T> only returns parsable values. So this value should get
// parsed, however it will be added to the 'invalid values' list and thus is not part of the collection
// returned by the enumerator.
headers.TryAddWithoutValidation(knownHeader, invalidHeaderValue);
// Only 1 value should get parsed (call to Add() with known header value).
Assert.Equal(1, headers.Parser.TryParseValueCallCount);
object storeValue = headers.GetParsedValues(knownHeader);
Assert.NotNull(storeValue);
// GetValues<T>() should trigger parsing of values added with TryAddWithoutValidation()
Assert.Equal(2, headers.Parser.TryParseValueCallCount);
// Since we added only one valid value to 'knownHeader', we expect GetValues() to return a that value.
Assert.Equal(parsedPrefix, storeValue);
}
示例4: GetParsedValues_GetValuesForExistingHeaderWithOnlyInvalidValues_ReturnsEmptyEnumerator
public void GetParsedValues_GetValuesForExistingHeaderWithOnlyInvalidValues_ReturnsEmptyEnumerator()
{
MockHeaders headers = new MockHeaders();
// Here we add an invalid value. GetValues<T> only returns parsable values. So this value should get
// parsed, however it will be added to the 'invalid values' list and thus is not part of the collection
// returned by the enumerator.
headers.TryAddWithoutValidation(knownHeader, invalidHeaderValue);
Assert.Equal(0, headers.Parser.TryParseValueCallCount);
object storeValue = headers.GetParsedValues(knownHeader);
Assert.Null(storeValue);
// GetValues<T>() should trigger parsing of values added with TryAddWithoutValidation()
Assert.Equal(1, headers.Parser.TryParseValueCallCount);
}
示例5: GetParsedValues_GetMultipleValuesForExistingHeader_ReturnsListOfValues
public void GetParsedValues_GetMultipleValuesForExistingHeader_ReturnsListOfValues()
{
MockHeaders headers = new MockHeaders();
headers.TryAddWithoutValidation("custom", rawPrefix + "0"); // this must not influence the result.
headers.Add(knownHeader, rawPrefix + "1");
headers.TryAddWithoutValidation(knownHeader, rawPrefix + "2");
// Only 1 value should get parsed (call to Add() with known header value).
Assert.Equal(1, headers.Parser.TryParseValueCallCount);
object storeValue = headers.GetParsedValues(knownHeader);
Assert.NotNull(storeValue);
// GetValues<T>() should trigger parsing of values added with TryAddWithoutValidation()
Assert.Equal(2, headers.Parser.TryParseValueCallCount);
// Since we added 2 values to header 'knownHeader', we expect GetValues() to return a List<T> with
// two values.
List<object> storeValues = storeValue as List<object>;
Assert.NotNull(storeValues);
Assert.Equal(2, storeValues.Count);
Assert.Equal(parsedPrefix + "1", storeValues[0]);
Assert.Equal(parsedPrefix + "2", storeValues[1]);
}
示例6: GetParsedValues_HeaderWithEmptyValues_ReturnsEmpty
public void GetParsedValues_HeaderWithEmptyValues_ReturnsEmpty()
{
MockHeaders headers = new MockHeaders();
headers.Add(knownHeader, string.Empty);
object storeValue = headers.GetParsedValues(knownHeader);
Assert.Null(storeValue);
}
示例7: GetParsedValues_GetSingleValueForExistingHeader_ReturnsAddedValue
public void GetParsedValues_GetSingleValueForExistingHeader_ReturnsAddedValue()
{
MockHeaders headers = new MockHeaders();
headers.Add("custom1", "customValue1");
// Get header values for non-existing header (but other headers exist in the store).
object storeValue = headers.GetParsedValues("custom1");
Assert.NotNull(storeValue);
// If we only have one value, then GetValues() should return just the value and not wrap it in a List<T>.
Assert.Equal("customValue1", storeValue);
}
示例8: GetParsedValues_GetValuesForNonExistingHeader_ReturnsNull
public void GetParsedValues_GetValuesForNonExistingHeader_ReturnsNull()
{
MockHeaders headers = new MockHeaders();
headers.Add("custom1", "customValue1");
// Get header values for non-existing header (but other headers exist in the store).
object storeValue = headers.GetParsedValues("doesntexist");
Assert.Null(storeValue);
}
示例9: GetParsedValues_GetValuesFromUninitializedHeaderStore_ReturnsNull
public void GetParsedValues_GetValuesFromUninitializedHeaderStore_ReturnsNull()
{
MockHeaders headers = new MockHeaders();
// Get header values from uninitialized store (store collection is null).
object storeValue = headers.GetParsedValues("doesntexist");
Assert.Null(storeValue);
}