From dd7537de4a4519aeb441a74761d46561898bfae4 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Wed, 16 Jul 2014 12:11:51 -0700 Subject: [PATCH] #103 Fix ambigious Keys property on IHeaderDictionary. --- .../IHeaderDictionary.cs | 6 ++++ .../HeaderDictionaryTests.cs | 31 +++++++++++++++++++ .../Microsoft.AspNet.PipelineCore.Tests.kproj | 3 +- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/Microsoft.AspNet.PipelineCore.Tests/HeaderDictionaryTests.cs diff --git a/src/Microsoft.AspNet.Http/IHeaderDictionary.cs b/src/Microsoft.AspNet.Http/IHeaderDictionary.cs index fecac4a0f4..e1304b5e5f 100644 --- a/src/Microsoft.AspNet.Http/IHeaderDictionary.cs +++ b/src/Microsoft.AspNet.Http/IHeaderDictionary.cs @@ -24,6 +24,12 @@ namespace Microsoft.AspNet.Http /// new int Count { get; } + // This property is duplicated to resolve an ambiguity between IReadableStringCollection.Keys and IDictionary.Keys + /// + /// Gets a collection containing the keys. + /// + new ICollection Keys { get; } + /// /// Get the associated values from the collection separated into individual values. /// Quoted values will not be split, and the quotes will be removed. diff --git a/test/Microsoft.AspNet.PipelineCore.Tests/HeaderDictionaryTests.cs b/test/Microsoft.AspNet.PipelineCore.Tests/HeaderDictionaryTests.cs new file mode 100644 index 0000000000..667f2dcb8a --- /dev/null +++ b/test/Microsoft.AspNet.PipelineCore.Tests/HeaderDictionaryTests.cs @@ -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(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")); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.PipelineCore.Tests/Microsoft.AspNet.PipelineCore.Tests.kproj b/test/Microsoft.AspNet.PipelineCore.Tests/Microsoft.AspNet.PipelineCore.Tests.kproj index 13a5649e18..09ea94747b 100644 --- a/test/Microsoft.AspNet.PipelineCore.Tests/Microsoft.AspNet.PipelineCore.Tests.kproj +++ b/test/Microsoft.AspNet.PipelineCore.Tests/Microsoft.AspNet.PipelineCore.Tests.kproj @@ -23,10 +23,11 @@ + - + \ No newline at end of file