1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
3
using System . Security . Cryptography . X509Certificates ;
4
+ using Autofac ;
4
5
using NSubstitute ;
5
6
using NUnit . Framework ;
6
7
@@ -78,10 +79,14 @@ public TestIReadOnlyListComponent(IReadOnlyList<IServiceItem> serviceItems)
78
79
[ Test ]
79
80
public void TestIEnumerableCorrectlyResolves ( )
80
81
{
81
- using ( var autosub = new AutoSubstitute ( ) )
82
+ using ( var autosub = new AutoSubstitute ( b =>
83
+ {
84
+ b . Provide < IServiceItem , ServiceItemA > ( ) ;
85
+ b . Provide < IServiceItem , ServiceItemB > ( ) ;
86
+ } ) )
82
87
{
83
- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
84
- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
88
+ var mockA = autosub . Resolve < ServiceItemA > ( ) ;
89
+ var mockB = autosub . Resolve < ServiceItemB > ( ) ;
85
90
var component = autosub . Resolve < TestIEnumerableComponent > ( ) ;
86
91
87
92
Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
@@ -93,10 +98,14 @@ public void TestIEnumerableCorrectlyResolves()
93
98
[ Test ]
94
99
public void TestIListCorrectlyResolves ( )
95
100
{
96
- using ( var autosub = new AutoSubstitute ( ) )
101
+ using ( var autosub = new AutoSubstitute ( b =>
97
102
{
98
- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
99
- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
103
+ b . Provide < IServiceItem , ServiceItemA > ( ) ;
104
+ b . Provide < IServiceItem , ServiceItemB > ( ) ;
105
+ } ) )
106
+ {
107
+ var mockA = autosub . Resolve < ServiceItemA > ( ) ;
108
+ var mockB = autosub . Resolve < ServiceItemB > ( ) ;
100
109
var component = autosub . Resolve < TestIListComponent > ( ) ;
101
110
102
111
Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
@@ -108,10 +117,14 @@ public void TestIListCorrectlyResolves()
108
117
[ Test ]
109
118
public void TestIReadOnlyCollectionCorrectlyResolves ( )
110
119
{
111
- using ( var autosub = new AutoSubstitute ( ) )
120
+ using ( var autosub = new AutoSubstitute ( b =>
121
+ {
122
+ b . Provide < IServiceItem , ServiceItemA > ( ) ;
123
+ b . Provide < IServiceItem , ServiceItemB > ( ) ;
124
+ } ) )
112
125
{
113
- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
114
- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
126
+ var mockA = autosub . Resolve < ServiceItemA > ( ) ;
127
+ var mockB = autosub . Resolve < ServiceItemB > ( ) ;
115
128
var component = autosub . Resolve < TestIReadOnlyCollectionComponent > ( ) ;
116
129
117
130
Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
@@ -123,10 +136,14 @@ public void TestIReadOnlyCollectionCorrectlyResolves()
123
136
[ Test ]
124
137
public void TestICollectionCorrectlyResolves ( )
125
138
{
126
- using ( var autosub = new AutoSubstitute ( ) )
139
+ using ( var autosub = new AutoSubstitute ( b =>
127
140
{
128
- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
129
- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
141
+ b . Provide < IServiceItem , ServiceItemA > ( ) ;
142
+ b . Provide < IServiceItem , ServiceItemB > ( ) ;
143
+ } ) )
144
+ {
145
+ var mockA = autosub . Resolve < ServiceItemA > ( ) ;
146
+ var mockB = autosub . Resolve < ServiceItemB > ( ) ;
130
147
var component = autosub . Resolve < TestICollectionComponent > ( ) ;
131
148
132
149
Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
@@ -138,10 +155,14 @@ public void TestICollectionCorrectlyResolves()
138
155
[ Test ]
139
156
public void TestIReadOnlyListCorrectlyResolves ( )
140
157
{
141
- using ( var autosub = new AutoSubstitute ( ) )
158
+ using ( var autosub = new AutoSubstitute ( b =>
159
+ {
160
+ b . Provide < IServiceItem , ServiceItemA > ( ) ;
161
+ b . Provide < IServiceItem , ServiceItemB > ( ) ;
162
+ } ) )
142
163
{
143
- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
144
- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
164
+ var mockA = autosub . Resolve < ServiceItemA > ( ) ;
165
+ var mockB = autosub . Resolve < ServiceItemB > ( ) ;
145
166
var component = autosub . Resolve < TestIReadOnlyListComponent > ( ) ;
146
167
147
168
Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
0 commit comments