diff --git a/src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs b/src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs deleted file mode 100644 index c86cf451b5..0000000000 --- a/src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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 Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Features; -using Microsoft.AspNet.Http.Internal; - -namespace Microsoft.AspNet.Hosting.Builder -{ - public class HttpContextFactory : IHttpContextFactory - { - private IHttpContextAccessor _httpContextAccessor; - - public HttpContextFactory(IHttpContextAccessor httpContextAccessor) - { - _httpContextAccessor = httpContextAccessor; - } - - public HttpContext CreateHttpContext(IFeatureCollection featureCollection) - { - var httpContext = new DefaultHttpContext(featureCollection); - _httpContextAccessor.HttpContext = httpContext; - return httpContext; - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Hosting/Builder/IHttpContextFactory.cs b/src/Microsoft.AspNet.Hosting/Builder/IHttpContextFactory.cs deleted file mode 100644 index ed1d9f4cc3..0000000000 --- a/src/Microsoft.AspNet.Hosting/Builder/IHttpContextFactory.cs +++ /dev/null @@ -1,13 +0,0 @@ -// 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 Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Features; - -namespace Microsoft.AspNet.Hosting.Builder -{ - public interface IHttpContextFactory - { - HttpContext CreateHttpContext(IFeatureCollection featureCollection); - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs b/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs deleted file mode 100644 index 02f3a2cc2c..0000000000 --- a/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs +++ /dev/null @@ -1,60 +0,0 @@ -// 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.Generic; -using Microsoft.AspNet.Hosting.Builder; -using Microsoft.AspNet.Http.Features; -using Microsoft.AspNet.Http.Internal; -using Microsoft.AspNet.Owin; -using Xunit; - -namespace Microsoft.AspNet.Hosting.Tests -{ - public class HttpContextFactoryFacts - { - [Fact] - public void CreateHttpContextSetsHttpContextAccessor() - { - // Arrange - var accessor = new HttpContextAccessor(); - var contextFactory = new HttpContextFactory(accessor); - - // Act - var context = contextFactory.CreateHttpContext(new FeatureCollection()); - - // Assert - Assert.True(ReferenceEquals(context, accessor.HttpContext)); - } - - [Fact] - public void Mutable_FeatureCollection_Wrapped_For_OwinFeatureCollection() - { - var env = new Dictionary(); - var contextFactory = new HttpContextFactory(new HttpContextAccessor()); - var context = contextFactory.CreateHttpContext(new FeatureCollection(new OwinFeatureCollection(env))); - - // Setting a feature will throw if the above feature collection is not wrapped in a mutable feature collection. - context.Features.Set(new CustomFeature(100)); - Assert.Equal(100, context.Features.Get().Value); - } - - private interface ICustomFeature - { - int Value { get; } - } - - private class CustomFeature : ICustomFeature - { - private readonly int _value; - public CustomFeature(int value) - { - _value = value; - } - - public int Value - { - get { return _value; } - } - } - } -} \ No newline at end of file