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


C# HttpHeaders.Count方法代码示例

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


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

示例1: AreEqual

        /// <summary>
        /// Asserts that the expected <see cref="HttpHeaders"/> instance is equal to the actual <see cref="actualHeaders"/> instance.
        /// </summary>
        /// <param name="expectedHeaders">The expected <see cref="HttpHeaders"/> instance. Should not be <c>null</c>.</param>
        /// <param name="actualHeaders">The actual <see cref="HttpHeaders"/> instance. Should not be <c>null</c>.</param>
        public static void AreEqual(HttpHeaders expectedHeaders, HttpHeaders actualHeaders)
        {
            Assert.IsNotNull(expectedHeaders, "The 'expectedHeaders' parameter should not be null.");
            Assert.IsNotNull(actualHeaders, "The 'actualHeaders' parameter should not be null.");

            Assert.AreEqual(expectedHeaders.Count(), actualHeaders.Count(), "The number of headers should have been the same.");

            foreach (KeyValuePair<string, IEnumerable<string>> expectedHeader in expectedHeaders)
            {
                KeyValuePair<string, IEnumerable<string>> actualHeader = actualHeaders.FirstOrDefault(h => h.Key == expectedHeader.Key);
                Assert.IsNotNull(actualHeader, string.Format("The '{0}' header was expected but not found.", expectedHeader.Key));

                if (expectedHeader.Key == "Date")
                {
                    HandleDateHeader(expectedHeader.Value.ToArray(), actualHeader.Value.ToArray());
                }
                else
                {
                    string expectedHeaderStr = string.Join(CommaSeperator, expectedHeader.Value);
                    string actualHeaderStr = string.Join(CommaSeperator, actualHeader.Value);
                    Assert.AreEqual(expectedHeaderStr, actualHeaderStr, string.Format("The '{0}' header disagreed with the expected header value.", expectedHeader.Key));
                }
            }
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:29,代码来源:HttpAssert.cs

示例2: Equal

        /// <summary>
        /// Asserts that the expected <see cref="HttpHeaders"/> instance is equal to the actual <see cref="actualHeaders"/> instance.
        /// </summary>
        /// <param name="expectedHeaders">The expected <see cref="HttpHeaders"/> instance. Should not be <c>null</c>.</param>
        /// <param name="actualHeaders">The actual <see cref="HttpHeaders"/> instance. Should not be <c>null</c>.</param>
        public void Equal(HttpHeaders expectedHeaders, HttpHeaders actualHeaders)
        {
            Assert.NotNull(expectedHeaders);
            Assert.NotNull(actualHeaders);

            Assert.Equal(expectedHeaders.Count(), actualHeaders.Count());

            foreach (KeyValuePair<string, IEnumerable<string>> expectedHeader in expectedHeaders)
            {
                KeyValuePair<string, IEnumerable<string>> actualHeader = actualHeaders.FirstOrDefault(h => h.Key == expectedHeader.Key);
                Assert.NotNull(actualHeader);

                if (expectedHeader.Key == "Date")
                {
                    HandleDateHeader(expectedHeader.Value.ToArray(), actualHeader.Value.ToArray());
                }
                else
                {
                    string expectedHeaderStr = string.Join(CommaSeperator, expectedHeader.Value);
                    string actualHeaderStr = string.Join(CommaSeperator, actualHeader.Value);
                    Assert.Equal(expectedHeaderStr, actualHeaderStr);
                }
            }
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:29,代码来源:HttpAssert.cs

示例3: HttpHeadersAddTest

		public void HttpHeadersAddTest()
		{
			var HttpHeaders = new HttpHeaders();
			Assert.AreEqual("[]", HttpHeaders.AsEnumerable<HttpHeader>().ToJsonString());
			HttpHeaders.Add("Content-Type", "text/html");
			HttpHeaders.Set("Content-Type", "text/plain");
			HttpHeaders.Set("cOntEnt-type", "text/plain");
			Assert.AreEqual(1, HttpHeaders.Count());
			Assert.AreEqual("cOntEnt-type: text/plain", String.Join("|", HttpHeaders.AsEnumerable()));
		}
开发者ID:soywiz,项目名称:NodeNetAsync,代码行数:10,代码来源:HttpHeadersTest.cs


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