Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
#310 Do not automatically wrap IFeatureCollections.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Oct 7, 2015
1 parent 7441855 commit f88b206
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class HttpContextFactory : IHttpContextFactory
{
public HttpContext CreateHttpContext(IFeatureCollection featureCollection)
{
return new DefaultHttpContext(new FeatureCollection(featureCollection));
return new DefaultHttpContext(featureCollection);
}
}
}
23 changes: 0 additions & 23 deletions test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,29 +308,6 @@ public void HostingEngine_CreatesDefaultRequestIdentifierFeature_IfNotPresent()
Assert.IsType<FastHttpRequestIdentifierFeature>(httpContext.Features.Get<IHttpRequestIdentifierFeature>());
}

[Fact]
public void Hosting_CreatesDefaultRequestIdentifierFeature_IfNotPresent_ForImmutableFeatureCollection()
{
// Arrange
HttpContext httpContext = null;
var requestDelegate = new RequestDelegate(innerHttpContext =>
{
httpContext = innerHttpContext;
return Task.FromResult(0);
});

_featuresSupportedByThisHost = new ReadOnlyFeatureCollection();

var hostingEngine = CreateHostingEngine(requestDelegate);

// Act
var disposable = hostingEngine.Start();

// Assert
Assert.NotNull(httpContext);
Assert.IsType<FastHttpRequestIdentifierFeature>(httpContext.Features.Get<IHttpRequestIdentifierFeature>());
}

[Fact]
public void HostingEngine_DoesNot_CreateDefaultRequestIdentifierFeature_IfPresent()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Mutable_FeatureCollection_Wrapped_For_OwinFeatureCollection()
{
var env = new Dictionary<string, object>();
var contextFactory = new HttpContextFactory();
var context = contextFactory.CreateHttpContext(new OwinFeatureCollection(env));
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<ICustomFeature>(new CustomFeature(100));
Expand Down

0 comments on commit f88b206

Please sign in to comment.