@@ -79,96 +79,76 @@ public TestIReadOnlyListComponent(IReadOnlyList<IServiceItem> serviceItems)
79
79
[ Test ]
80
80
public void TestIEnumerableCorrectlyResolves ( )
81
81
{
82
- using ( var autosub = new AutoSubstitute ( b =>
83
- {
84
- b . Provide < IServiceItem , ServiceItemA > ( ) ;
85
- b . Provide < IServiceItem , ServiceItemB > ( ) ;
86
- } ) )
87
- {
88
- var mockA = autosub . Resolve < ServiceItemA > ( ) ;
89
- var mockB = autosub . Resolve < ServiceItemB > ( ) ;
90
- var component = autosub . Resolve < TestIEnumerableComponent > ( ) ;
82
+ using var autosub = AutoSubstitute . Configure ( )
83
+ . Provide < IServiceItem , ServiceItemA > ( out var mockA )
84
+ . Provide < IServiceItem , ServiceItemB > ( out var mockB )
85
+ . Build ( ) ;
91
86
92
- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
93
- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
94
- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
95
- }
87
+ var component = autosub . Resolve < TestIEnumerableComponent > ( ) ;
88
+
89
+ Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
90
+ Assert . That ( component . ServiceItems . Contains ( mockA . Value ) , Is . True ) ;
91
+ Assert . That ( component . ServiceItems . Contains ( mockB . Value ) , Is . True ) ;
96
92
}
97
93
98
94
[ Test ]
99
95
public void TestIListCorrectlyResolves ( )
100
96
{
101
- using ( var autosub = new AutoSubstitute ( b =>
102
- {
103
- b . Provide < IServiceItem , ServiceItemA > ( ) ;
104
- b . Provide < IServiceItem , ServiceItemB > ( ) ;
105
- } ) )
106
- {
107
- var mockA = autosub . Resolve < ServiceItemA > ( ) ;
108
- var mockB = autosub . Resolve < ServiceItemB > ( ) ;
109
- var component = autosub . Resolve < TestIListComponent > ( ) ;
97
+ using var autosub = AutoSubstitute . Configure ( )
98
+ . Provide < IServiceItem , ServiceItemA > ( out var mockA )
99
+ . Provide < IServiceItem , ServiceItemB > ( out var mockB )
100
+ . Build ( ) ;
110
101
111
- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
112
- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
113
- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
114
- }
102
+ var component = autosub . Resolve < TestIListComponent > ( ) ;
103
+
104
+ Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
105
+ Assert . That ( component . ServiceItems . Contains ( mockA . Value ) , Is . True ) ;
106
+ Assert . That ( component . ServiceItems . Contains ( mockB . Value ) , Is . True ) ;
115
107
}
116
108
117
109
[ Test ]
118
110
public void TestIReadOnlyCollectionCorrectlyResolves ( )
119
111
{
120
- using ( var autosub = new AutoSubstitute ( b =>
121
- {
122
- b . Provide < IServiceItem , ServiceItemA > ( ) ;
123
- b . Provide < IServiceItem , ServiceItemB > ( ) ;
124
- } ) )
125
- {
126
- var mockA = autosub . Resolve < ServiceItemA > ( ) ;
127
- var mockB = autosub . Resolve < ServiceItemB > ( ) ;
128
- var component = autosub . Resolve < TestIReadOnlyCollectionComponent > ( ) ;
112
+ using var autosub = AutoSubstitute . Configure ( )
113
+ . Provide < IServiceItem , ServiceItemA > ( out var mockA )
114
+ . Provide < IServiceItem , ServiceItemB > ( out var mockB )
115
+ . Build ( ) ;
129
116
130
- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
131
- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
132
- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
133
- }
117
+ var component = autosub . Resolve < TestIReadOnlyCollectionComponent > ( ) ;
118
+
119
+ Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
120
+ Assert . That ( component . ServiceItems . Contains ( mockA . Value ) , Is . True ) ;
121
+ Assert . That ( component . ServiceItems . Contains ( mockB . Value ) , Is . True ) ;
134
122
}
135
123
136
124
[ Test ]
137
125
public void TestICollectionCorrectlyResolves ( )
138
126
{
139
- using ( var autosub = new AutoSubstitute ( b =>
140
- {
141
- b . Provide < IServiceItem , ServiceItemA > ( ) ;
142
- b . Provide < IServiceItem , ServiceItemB > ( ) ;
143
- } ) )
144
- {
145
- var mockA = autosub . Resolve < ServiceItemA > ( ) ;
146
- var mockB = autosub . Resolve < ServiceItemB > ( ) ;
147
- var component = autosub . Resolve < TestICollectionComponent > ( ) ;
127
+ using var autosub = AutoSubstitute . Configure ( )
128
+ . Provide < IServiceItem , ServiceItemA > ( out var mockA )
129
+ . Provide < IServiceItem , ServiceItemB > ( out var mockB )
130
+ . Build ( ) ;
148
131
149
- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
150
- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
151
- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
152
- }
132
+ var component = autosub . Resolve < TestICollectionComponent > ( ) ;
133
+
134
+ Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
135
+ Assert . That ( component . ServiceItems . Contains ( mockA . Value ) , Is . True ) ;
136
+ Assert . That ( component . ServiceItems . Contains ( mockB . Value ) , Is . True ) ;
153
137
}
154
138
155
139
[ Test ]
156
140
public void TestIReadOnlyListCorrectlyResolves ( )
157
141
{
158
- using ( var autosub = new AutoSubstitute ( b =>
159
- {
160
- b . Provide < IServiceItem , ServiceItemA > ( ) ;
161
- b . Provide < IServiceItem , ServiceItemB > ( ) ;
162
- } ) )
163
- {
164
- var mockA = autosub . Resolve < ServiceItemA > ( ) ;
165
- var mockB = autosub . Resolve < ServiceItemB > ( ) ;
166
- var component = autosub . Resolve < TestIReadOnlyListComponent > ( ) ;
142
+ using var autosub = AutoSubstitute . Configure ( )
143
+ . Provide < IServiceItem , ServiceItemA > ( out var mockA )
144
+ . Provide < IServiceItem , ServiceItemB > ( out var mockB )
145
+ . Build ( ) ;
167
146
168
- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
169
- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
170
- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
171
- }
147
+ var component = autosub . Resolve < TestIReadOnlyListComponent > ( ) ;
148
+
149
+ Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
150
+ Assert . That ( component . ServiceItems . Contains ( mockA . Value ) , Is . True ) ;
151
+ Assert . That ( component . ServiceItems . Contains ( mockB . Value ) , Is . True ) ;
172
152
}
173
153
}
174
154
}
0 commit comments