#103 Fix ambigious Keys property on IHeaderDictionary.

This commit is contained in:
Chris Ross 2014-07-16 12:11:51 -07:00
parent 8ab566e049
commit dd7537de4a
3 changed files with 39 additions and 1 deletions

View File

@ -24,6 +24,12 @@ namespace Microsoft.AspNet.Http
/// </summary>
new int Count { get; }
// This property is duplicated to resolve an ambiguity between IReadableStringCollection.Keys and IDictionary<string, string[]>.Keys
/// <summary>
/// Gets a collection containing the keys.
/// </summary>
new ICollection<string> Keys { get; }
/// <summary>
/// Get the associated values from the collection separated into individual values.
/// Quoted values will not be split, and the quotes will be removed.

View File

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.AspNet.PipelineCore.Collections;
using Xunit;
namespace Microsoft.AspNet.PipelineCore.Tests
{
public class HeaderDictionaryTests
{
[Fact]
public void PropertiesAreAccessible()
{
var headers = new HeaderDictionary(
new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase)
{
{ "Header1", new[] { "Value1" } }
});
Assert.Equal(1, headers.Count);
Assert.Equal(new[] { "Headers1" }, headers.Keys);
Assert.True(headers.ContainsKey("headers1"));
Assert.False(headers.ContainsKey("headers2"));
Assert.Equal("Value1", headers["header1"]);
Assert.Equal("Value1", headers.Get("header1"));
Assert.Equal(new[] { "Value1" }, headers.GetValues("header1"));
}
}
}

View File

@ -23,10 +23,11 @@
<ItemGroup>
<Compile Include="BuilderTests.cs" />
<Compile Include="FormFeatureTests.cs" />
<Compile Include="HeaderDictionaryTests.cs" />
<Compile Include="QueryFeatureTests.cs" />
<Compile Include="DefaultHttpContextTests.cs" />
<Compile Include="DefaultHttpRequestTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
</Project>