diff --git a/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs b/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs new file mode 100644 index 0000000000..b6ab156902 --- /dev/null +++ b/test/Microsoft.AspNet.Hosting.Tests/HttpContextFactoryFacts.cs @@ -0,0 +1,44 @@ +// 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.Collections.Generic; +using Microsoft.AspNet.Hosting.Builder; +using Microsoft.AspNet.Owin; +using Xunit; + +namespace Microsoft.AspNet.Hosting.Tests +{ + public class HttpContextFactoryFacts + { + [Fact] + public void Mutable_FeatureCollection_Wrapped_For_OwinFeatureCollection() + { + var env = new Dictionary(); + var contextFactory = new HttpContextFactory(); + var context = contextFactory.CreateHttpContext(new OwinFeatureCollection(env)); + + // Setting a feature will throw if the above feature collection is not wrapped in a mutable feature collection. + context.SetFeature(new CustomFeature(100)); + Assert.Equal(100, context.GetFeature().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 diff --git a/test/Microsoft.AspNet.Hosting.Tests/project.json b/test/Microsoft.AspNet.Hosting.Tests/project.json index 8adf1a1d0e..49c5506d3a 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/project.json +++ b/test/Microsoft.AspNet.Hosting.Tests/project.json @@ -1,14 +1,15 @@ { "dependencies": { "Microsoft.AspNet.Hosting": "1.0.0-*", + "Microsoft.AspNet.Owin": "1.0.0-*", "Microsoft.AspNet.RequestContainer": "1.0.0-*", "xunit.runner.kre": "1.0.0-*" }, "frameworks": { - "aspnet50": { } + "aspnet50": {} }, "commands": { "test": "xunit.runner.kre" }, "webroot": "testroot" -} +} \ No newline at end of file