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


C# MockHeaders.GetHeaderStrings方法代码示例

本文整理汇总了C#中MockHeaders.GetHeaderStrings方法的典型用法代码示例。如果您正苦于以下问题:C# MockHeaders.GetHeaderStrings方法的具体用法?C# MockHeaders.GetHeaderStrings怎么用?C# MockHeaders.GetHeaderStrings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MockHeaders的用法示例。


在下文中一共展示了MockHeaders.GetHeaderStrings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetHeaderStrings_SetMultipleHeaders_AllHeaderValuesReturned

        public void GetHeaderStrings_SetMultipleHeaders_AllHeaderValuesReturned()
        {
            MockHeaderParser parser = new MockHeaderParser(true);
            MockHeaders headers = new MockHeaders(parser);

            // Add header value with invalid newline chars.
            headers.Add(knownHeader, rawPrefix + "1");
            headers.Add("header2", "value2");
            headers.Add("header3", (string)null);
            headers.Add("header4", "value41");
            headers.Add("header4", "value42");

            string[] expectedHeaderNames = { knownHeader, "header2", "header3", "header4" };
            string[] expectedHeaderValues = { parsedPrefix + "1", "value2", "", "value41, value42" };
            int i = 0;

            foreach (var header in headers.GetHeaderStrings())
            {
                Assert.NotEqual(expectedHeaderNames.Length, i);
                Assert.Equal(expectedHeaderNames[i], header.Key);
                Assert.Equal(expectedHeaderValues[i], header.Value);
                i++;
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:24,代码来源:HttpHeadersTest.cs

示例2: GetHeaderStrings_SetMultipleValuesOnSingleValueHeader_AllHeaderValuesReturned

        public void GetHeaderStrings_SetMultipleValuesOnSingleValueHeader_AllHeaderValuesReturned()
        {
            MockHeaderParser parser = new MockHeaderParser(false);
            MockHeaders headers = new MockHeaders(parser);

            headers.TryAddWithoutValidation(knownHeader, "value1");
            headers.TryAddWithoutValidation(knownHeader, rawPrefix);

            foreach (var header in headers.GetHeaderStrings())
            {
                Assert.Equal(knownHeader, header.Key);
                // Note that the added rawPrefix did not get parsed
                Assert.Equal("value1, " + rawPrefix, header.Value);
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:15,代码来源:HttpHeadersTest.cs

示例3: GetHeaderStrings_SetValidAndInvalidHeaderValues_AllHeaderValuesReturned

        public void GetHeaderStrings_SetValidAndInvalidHeaderValues_AllHeaderValuesReturned()
        {
            MockHeaderParser parser = new MockHeaderParser("---");
            MockHeaders headers = new MockHeaders(parser);

            // Add header value with invalid newline chars.
            headers.Add(knownHeader, rawPrefix + "1");
            headers.TryAddWithoutValidation(knownHeader, "value2,value3");
            headers.TryAddWithoutValidation(knownHeader, invalidHeaderValue);

            foreach (var header in headers.GetHeaderStrings())
            {
                Assert.Equal(knownHeader, header.Key);
                // Note that raw values don't get parsed but just added to the result.
                Assert.Equal("value2,value3---" + invalidHeaderValue + "---" + parsedPrefix + "1", header.Value);
            }
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:17,代码来源:HttpHeadersTest.cs


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