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


C# HttpRequestHeaderHelper.GetHttpHeaderWithQValues方法代码示例

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


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

示例1: GetHttpHeaderWithQValues_NoHttpHeaderQValues_EmptyList

        public void GetHttpHeaderWithQValues_NoHttpHeaderQValues_EmptyList()
        {
            //Arrange
            var httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
            var headerValue = string.Empty;
            var headerType = HttpRequestHeader.AcceptEncoding;
            var headerName = (string)headerType;

            httpRequest.Expect(x => x.Headers[headerName]).Return(headerValue);

            //Act
            var httpRequestHeaderHelper = new HttpRequestHeaderHelper();
            var headerValueWithQValues = httpRequestHeaderHelper.GetHttpHeaderWithQValues(httpRequest, headerType);

            //Assert
            httpRequest.VerifyAllExpectations();
            Assert.IsEmpty(headerValueWithQValues);
        }
开发者ID:CSharpDev,项目名称:talifun-web,代码行数:18,代码来源:HttpRequestHeaderHelperTests.cs

示例2: GetHttpHeaderWithQValues_IsCaseSensitive_List

        public void GetHttpHeaderWithQValues_IsCaseSensitive_List()
        {
            //Arrange
            var httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
            var headerValue = "abcdeF";
            var headerType = HttpRequestHeader.AcceptEncoding;
            var headerName = (string)headerType;

            httpRequest.Expect(x => x.Headers[headerName]).Return(headerValue);

            //Act
            var httpRequestHeaderHelper = new HttpRequestHeaderHelper();
            var headerValueWithQValues = httpRequestHeaderHelper.GetHttpHeaderWithQValues(httpRequest, headerType);

            //Assert
            httpRequest.VerifyAllExpectations();
            Assert.AreEqual(1, headerValueWithQValues.Count);
            Assert.AreEqual(headerValue, headerValueWithQValues[0].Identity);
            Assert.IsNull(headerValueWithQValues[0].QValue);
        }
开发者ID:CSharpDev,项目名称:talifun-web,代码行数:20,代码来源:HttpRequestHeaderHelperTests.cs

示例3: GetHttpHeaderWithQValues_MultipleHttpHeaderWithQValueSet_List

        public void GetHttpHeaderWithQValues_MultipleHttpHeaderWithQValueSet_List()
        {
            //Arrange
            var httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
            var identity1 = "gzip";
            var qValue1 = 0.5f;

            var identity2 = "deflate";
            var qValue2 = 0.8f;

            var headerValue = identity1 + ";q=" + qValue1.ToString("N1") + "," + identity2 + ";q=" + qValue2.ToString("N1");
            var headerType = HttpRequestHeader.AcceptEncoding;
            var headerName = (string)headerType;

            httpRequest.Expect(x => x.Headers[headerName]).Return(headerValue);

            //Act
            var httpRequestHeaderHelper = new HttpRequestHeaderHelper();
            var headerValueWithQValues = httpRequestHeaderHelper.GetHttpHeaderWithQValues(httpRequest, headerType);

            //Assert
            httpRequest.VerifyAllExpectations();
            Assert.AreEqual(2, headerValueWithQValues.Count);

            Assert.AreEqual(identity1, headerValueWithQValues[0].Identity);
            Assert.IsNotNull(headerValueWithQValues[0].QValue);
            Assert.AreEqual(qValue1, headerValueWithQValues[0].QValue.Value);

            Assert.AreEqual(identity2, headerValueWithQValues[1].Identity);
            Assert.IsNotNull(headerValueWithQValues[1].QValue);
            Assert.AreEqual(qValue2, headerValueWithQValues[1].QValue.Value);
        }
开发者ID:CSharpDev,项目名称:talifun-web,代码行数:32,代码来源:HttpRequestHeaderHelperTests.cs

示例4: GetHttpHeaderWithQValues_InvalidQValueNotANumber_List

        public void GetHttpHeaderWithQValues_InvalidQValueNotANumber_List()
        {
            //Arrange
            var httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
            var headerValue = "gzip, deflate, x-gzip, identity; q=moo";
            var headerType = HttpRequestHeader.AcceptEncoding;
            var headerName = (string)headerType;

            httpRequest.Expect(x => x.Headers[headerName]).Return(headerValue);

            //Act
            var httpRequestHeaderHelper = new HttpRequestHeaderHelper();
            var headerValueWithQValues = httpRequestHeaderHelper.GetHttpHeaderWithQValues(httpRequest, headerType);

            //Assert
            httpRequest.VerifyAllExpectations();
            Assert.AreEqual(5, headerValueWithQValues.Count);
            Assert.AreEqual("identity", headerValueWithQValues[3].Identity);
            Assert.IsNull(headerValueWithQValues[3].QValue);
            Assert.AreEqual("q=moo", headerValueWithQValues[4].Identity);
            Assert.IsNull(headerValueWithQValues[4].QValue);
        }
开发者ID:CSharpDev,项目名称:talifun-web,代码行数:22,代码来源:HttpRequestHeaderHelperTests.cs


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