本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}