This repository was archived by the owner on Dec 19, 2018. It is now read-only.
File tree 2 files changed +47
-2
lines changed
test/Microsoft.AspNet.Hosting.Tests 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
2
+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
+
4
+ using System . Collections . Generic ;
5
+ using Microsoft . AspNet . Hosting . Builder ;
6
+ using Microsoft . AspNet . Owin ;
7
+ using Xunit ;
8
+
9
+ namespace Microsoft . AspNet . Hosting . Tests
10
+ {
11
+ public class HttpContextFactoryFacts
12
+ {
13
+ [ Fact ]
14
+ public void Mutable_FeatureCollection_Wrapped_For_OwinFeatureCollection ( )
15
+ {
16
+ var env = new Dictionary < string , object > ( ) ;
17
+ var contextFactory = new HttpContextFactory ( ) ;
18
+ var context = contextFactory . CreateHttpContext ( new OwinFeatureCollection ( env ) ) ;
19
+
20
+ // Setting a feature will throw if the above feature collection is not wrapped in a mutable feature collection.
21
+ context . SetFeature < ICustomFeature > ( new CustomFeature ( 100 ) ) ;
22
+ Assert . Equal ( 100 , context . GetFeature < ICustomFeature > ( ) . Value ) ;
23
+ }
24
+
25
+ private interface ICustomFeature
26
+ {
27
+ int Value { get ; }
28
+ }
29
+
30
+ private class CustomFeature : ICustomFeature
31
+ {
32
+ private readonly int _value ;
33
+ public CustomFeature ( int value )
34
+ {
35
+ _value = value ;
36
+ }
37
+
38
+ public int Value
39
+ {
40
+ get { return _value ; }
41
+ }
42
+ }
43
+ }
44
+ }
Original file line number Diff line number Diff line change 1
1
{
2
2
"dependencies" : {
3
3
"Microsoft.AspNet.Hosting" : " 1.0.0-*" ,
4
+ "Microsoft.AspNet.Owin" : " 1.0.0-*" ,
4
5
"Microsoft.AspNet.RequestContainer" : " 1.0.0-*" ,
5
6
"xunit.runner.kre" : " 1.0.0-*"
6
7
},
7
8
"frameworks" : {
8
- "aspnet50" : { }
9
+ "aspnet50" : {}
9
10
},
10
11
"commands" : {
11
12
"test" : " xunit.runner.kre"
12
13
},
13
14
"webroot" : " testroot"
14
- }
15
+ }
You can’t perform that action at this time.
0 commit comments