#310 Do not automatically wrap IFeatureCollections.

This commit is contained in:
Chris R 2015-10-07 09:20:12 -07:00
parent 7441855c34
commit f88b206082
3 changed files with 2 additions and 25 deletions

View File

@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Hosting.Builder
{
public HttpContext CreateHttpContext(IFeatureCollection featureCollection)
{
return new DefaultHttpContext(new FeatureCollection(featureCollection));
return new DefaultHttpContext(featureCollection);
}
}
}

View File

@ -308,29 +308,6 @@ namespace Microsoft.AspNet.Hosting
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()
{

View File

@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Hosting.Tests
{
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));