From 1b02cd2baf06ddec7ffa030546e709819d8ccfb4 Mon Sep 17 00:00:00 2001 From: kchanlee Date: Mon, 13 Mar 2017 22:54:57 +0800 Subject: [PATCH] Implement `OwinEnvironment` `IEnumerable.GetEnumerator()` (#789) --- src/Microsoft.AspNetCore.Owin/OwinEnvironment.cs | 4 ++-- .../OwinEnvironmentTests.cs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Owin/OwinEnvironment.cs b/src/Microsoft.AspNetCore.Owin/OwinEnvironment.cs index 4d30f52cec..165c3eece4 100644 --- a/src/Microsoft.AspNetCore.Owin/OwinEnvironment.cs +++ b/src/Microsoft.AspNetCore.Owin/OwinEnvironment.cs @@ -270,7 +270,7 @@ namespace Microsoft.AspNetCore.Owin throw new NotImplementedException(); } - IEnumerator> IEnumerable>.GetEnumerator() + public IEnumerator> GetEnumerator() { foreach (var entryPair in _entries) { @@ -288,7 +288,7 @@ namespace Microsoft.AspNetCore.Owin IEnumerator IEnumerable.GetEnumerator() { - throw new NotImplementedException(); + return GetEnumerator(); } public class FeatureMap diff --git a/test/Microsoft.AspNetCore.Owin.Tests/OwinEnvironmentTests.cs b/test/Microsoft.AspNetCore.Owin.Tests/OwinEnvironmentTests.cs index 7cd6ef8826..b728802914 100644 --- a/test/Microsoft.AspNetCore.Owin.Tests/OwinEnvironmentTests.cs +++ b/test/Microsoft.AspNetCore.Owin.Tests/OwinEnvironmentTests.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -129,6 +130,15 @@ namespace Microsoft.AspNetCore.Owin Assert.Equal("1.0", env["owin.Version"]); } + [Fact] + public void OwinEnvironmentImpelmentsGetEnumerator() + { + var owinEnvironment = new OwinEnvironment(CreateContext()); + + Assert.NotNull(owinEnvironment.GetEnumerator()); + Assert.NotNull(((IEnumerable)owinEnvironment).GetEnumerator()); + } + private HttpContext CreateContext() { var context = new DefaultHttpContext();