11using System . Collections . Generic ;
22using System . Linq ;
33using System . Security . Cryptography . X509Certificates ;
4+ using Autofac ;
45using NSubstitute ;
56using NUnit . Framework ;
67
@@ -78,76 +79,76 @@ public TestIReadOnlyListComponent(IReadOnlyList<IServiceItem> serviceItems)
7879 [ Test ]
7980 public void TestIEnumerableCorrectlyResolves ( )
8081 {
81- using ( var autosub = new AutoSubstitute ( ) )
82- {
83- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
84- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
85- 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 ( ) ;
8686
87- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
88- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
89- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
90- }
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 ) ;
9192 }
9293
9394 [ Test ]
9495 public void TestIListCorrectlyResolves ( )
9596 {
96- using ( var autosub = new AutoSubstitute ( ) )
97- {
98- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
99- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
100- 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 ( ) ;
101101
102- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
103- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
104- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
105- }
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 ) ;
106107 }
107108
108109 [ Test ]
109110 public void TestIReadOnlyCollectionCorrectlyResolves ( )
110111 {
111- using ( var autosub = new AutoSubstitute ( ) )
112- {
113- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
114- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
115- 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 ( ) ;
116116
117- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
118- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
119- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
120- }
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 ) ;
121122 }
122123
123124 [ Test ]
124125 public void TestICollectionCorrectlyResolves ( )
125126 {
126- using ( var autosub = new AutoSubstitute ( ) )
127- {
128- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
129- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
130- 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 ( ) ;
131131
132- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
133- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
134- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
135- }
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 ) ;
136137 }
137138
138139 [ Test ]
139140 public void TestIReadOnlyListCorrectlyResolves ( )
140141 {
141- using ( var autosub = new AutoSubstitute ( ) )
142- {
143- var mockA = autosub . Provide < IServiceItem , ServiceItemA > ( ) ;
144- var mockB = autosub . Provide < IServiceItem , ServiceItemB > ( ) ;
145- 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 ( ) ;
146146
147- Assert . That ( component . ServiceItems , Is . Not . Empty ) ;
148- Assert . That ( component . ServiceItems . Contains ( mockA ) , Is . True ) ;
149- Assert . That ( component . ServiceItems . Contains ( mockB ) , Is . True ) ;
150- }
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 ) ;
151152 }
152153 }
153154}
0 commit comments