@@ -8,26 +8,69 @@ public class GHIssue535_Property_injection_does_not_work_when_appending_implemen
8
8
{
9
9
public int Run ( )
10
10
{
11
- Test ( ) ;
11
+ // Test1();
12
+ Test2 ( ) ;
12
13
return 1 ;
13
14
}
14
15
15
- [ Test ]
16
- [ Ignore ( "fixme" ) ]
17
- public void Test ( )
16
+ // [Test]
17
+ public void Test1 ( )
18
18
{
19
19
// ARRANGE
20
20
const string testFoo1 = "TF1" ;
21
21
const string testFoo2 = "TF2" ;
22
22
23
23
var container = new Container ( ) ;
24
24
25
- container . RegisterMany ( new [ ] { typeof ( Foo1 ) , typeof ( IFoo ) } , typeof ( Foo1 ) , reuse : Reuse . Singleton ) ;
26
25
var propertiesAndFieldsSelector = PropertiesAndFields . Of . Name ( nameof ( IFoo . Test ) , _ => testFoo1 ) ;
27
- container . RegisterMany ( new [ ] { typeof ( Foo1 ) , typeof ( IFoo ) } , typeof ( Foo1 ) , reuse : Reuse . Singleton ,
26
+ container . RegisterMany ( new [ ] { typeof ( Foo1 ) , typeof ( IFoo ) } , typeof ( Foo1 ) , reuse : Reuse . Singleton ,
27
+ made : propertiesAndFieldsSelector , ifAlreadyRegistered : IfAlreadyRegistered . AppendNewImplementation ) ;
28
+
29
+ propertiesAndFieldsSelector = PropertiesAndFields . Of . Name ( nameof ( IFoo . Test ) , _ => testFoo2 ) ;
30
+ container . RegisterMany ( new [ ] { typeof ( Foo2 ) , typeof ( IFoo ) } , typeof ( Foo2 ) , reuse : Reuse . Singleton ,
31
+ made : propertiesAndFieldsSelector , ifAlreadyRegistered : IfAlreadyRegistered . AppendNewImplementation ) ;
32
+
33
+ // ACT
34
+ var foo1 = container . Resolve < Foo1 > ( ) ;
35
+ var foo2 = container . Resolve < Foo2 > ( ) ;
36
+ var foos = container . Resolve < IEnumerable < IFoo > > ( ) ;
37
+
38
+ // ASSERT
39
+ Assert . AreEqual ( testFoo1 , foo1 . Test ) ;
40
+ Assert . AreEqual ( testFoo2 , foo2 . Test ) ;
41
+
42
+ foreach ( var foo in foos )
43
+ {
44
+ switch ( foo )
45
+ {
46
+ case Foo1 foo1FromEnumerable :
47
+ Assert . AreEqual ( testFoo1 , foo . Test ) ;
48
+ Assert . AreEqual ( foo1 , foo1FromEnumerable ) ;
49
+ break ;
50
+ case Foo2 foo2FromEnumerable :
51
+ Assert . AreEqual ( testFoo2 , foo . Test ) ;
52
+ Assert . AreEqual ( foo2 , foo2FromEnumerable ) ;
53
+ break ;
54
+ }
55
+ }
56
+ }
57
+
58
+ // [Test]
59
+ public void Test2 ( )
60
+ {
61
+ // ARRANGE
62
+ const string testFoo1 = "TF1" ;
63
+ const string testFoo2 = "TF2" ;
64
+
65
+ var container = new Container ( ) ;
66
+
67
+ // container.RegisterMany(new[] { typeof(Foo1), typeof(IFoo) }, typeof(Foo1), reuse: Reuse.Singleton);
68
+ var propertiesAndFieldsSelector = PropertiesAndFields . Of . Name ( nameof ( IFoo . Test ) , _ => testFoo1 ) ;
69
+ container . RegisterMany ( new [ ] { typeof ( Foo1 ) , typeof ( IFoo ) } , typeof ( Foo1 ) , reuse : Reuse . Singleton ,
28
70
made : propertiesAndFieldsSelector , ifAlreadyRegistered : IfAlreadyRegistered . AppendNewImplementation ) ;
29
71
30
72
container . RegisterMany ( new [ ] { typeof ( Foo2 ) , typeof ( IFoo ) } , typeof ( Foo2 ) , reuse : Reuse . Singleton ) ;
73
+
31
74
propertiesAndFieldsSelector = PropertiesAndFields . Of . Name ( nameof ( IFoo . Test ) , _ => testFoo2 ) ;
32
75
container . RegisterMany ( new [ ] { typeof ( Foo2 ) , typeof ( IFoo ) } , typeof ( Foo2 ) , reuse : Reuse . Singleton ,
33
76
made : propertiesAndFieldsSelector , ifAlreadyRegistered : IfAlreadyRegistered . AppendNewImplementation ) ;
0 commit comments