@@ -9,214 +9,210 @@ namespace Autofac.Extras.Tests.MvvmCross
99 [ TestFixture ]
1010 public class AutofacMvxIocProviderFixture
1111 {
12- private IContainer container ;
13- private AutofacMvxIocProvider provider ;
12+ IContainer _container ;
13+ AutofacMvxIocProvider _provider ;
1414
1515 [ SetUp ]
1616 public void SetUp ( )
1717 {
18- container = new ContainerBuilder ( ) . Build ( ) ;
19- provider = new AutofacMvxIocProvider ( container ) ;
18+ _container = new ContainerBuilder ( ) . Build ( ) ;
19+ _provider = new AutofacMvxIocProvider ( _container ) ;
2020 }
2121
2222 [ TearDown ]
2323 public void TearDown ( )
2424 {
25- provider . Dispose ( ) ;
25+ _provider . Dispose ( ) ;
2626 }
2727
2828 [ Test ]
2929 public void CanResolveReturnsTrueWhenMatchingTypeIsRegistered ( )
3030 {
3131 var builder = new ContainerBuilder ( ) ;
3232 builder . Register ( c => new object ( ) ) ;
33- builder . Update ( container ) ;
33+ builder . Update ( _container ) ;
3434
35- Assert . That ( provider . CanResolve < object > ( ) , Is . True ) ;
35+ Assert . That ( _provider . CanResolve < object > ( ) , Is . True ) ;
3636 }
3737
3838 [ Test ]
3939 public void CanResolveReturnsFalseWhenNoMatchingTypeIsRegistered ( )
4040 {
41- Assert . That ( provider . CanResolve < object > ( ) , Is . False ) ;
41+ Assert . That ( _provider . CanResolve < object > ( ) , Is . False ) ;
4242 }
4343
4444 [ Test ]
4545 public void CanResolveThrowsArgumentNullExceptionWhenCalledWithNoTypeArgument ( )
4646 {
47- Assert . That ( ( ) => provider . CanResolve ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
47+ Assert . That ( ( ) => _provider . CanResolve ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
4848 }
4949
5050 [ Test ]
5151 public void ResolveCreateAndIoCConstructReturnsRegisteredType ( )
5252 {
5353 var builder = new ContainerBuilder ( ) ;
5454 builder . Register ( c => new object ( ) ) ;
55- builder . Update ( container ) ;
55+ builder . Update ( _container ) ;
5656
57- Assert . That ( provider . Resolve < object > ( ) , Is . TypeOf < object > ( ) ) ;
58- Assert . That ( provider . Create < object > ( ) , Is . TypeOf < object > ( ) ) ;
59- Assert . That ( provider . IoCConstruct < object > ( ) , Is . TypeOf < object > ( ) ) ;
57+ Assert . That ( _provider . Resolve < object > ( ) , Is . TypeOf < object > ( ) ) ;
58+ Assert . That ( _provider . Create < object > ( ) , Is . TypeOf < object > ( ) ) ;
59+ Assert . That ( _provider . IoCConstruct < object > ( ) , Is . TypeOf < object > ( ) ) ;
6060 }
6161
6262 [ Test ]
6363 public void ResolveCreateAndIoCConstructThrowsComponentNotRegisteredExceptionWhenNoTypeRegistered ( )
6464 {
65- Assert . That ( ( ) => provider . Resolve < object > ( ) , Throws . TypeOf < ComponentNotRegisteredException > ( ) ) ;
66- Assert . That ( ( ) => provider . Create < object > ( ) , Throws . TypeOf < ComponentNotRegisteredException > ( ) ) ;
67- Assert . That ( ( ) => provider . IoCConstruct < object > ( ) , Throws . TypeOf < ComponentNotRegisteredException > ( ) ) ;
65+ Assert . That ( ( ) => _provider . Resolve < object > ( ) , Throws . TypeOf < ComponentNotRegisteredException > ( ) ) ;
66+ Assert . That ( ( ) => _provider . Create < object > ( ) , Throws . TypeOf < ComponentNotRegisteredException > ( ) ) ;
67+ Assert . That ( ( ) => _provider . IoCConstruct < object > ( ) , Throws . TypeOf < ComponentNotRegisteredException > ( ) ) ;
6868 }
6969
7070 [ Test ]
7171 public void ResolveCreateAndIoCConstructThrowsArgumentNullExceptionWhenCalledWithNoTypeArgument ( )
7272 {
73- Assert . That ( ( ) => provider . Resolve ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
74- Assert . That ( ( ) => provider . Create ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
75- Assert . That ( ( ) => provider . IoCConstruct ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
73+ Assert . That ( ( ) => _provider . Resolve ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
74+ Assert . That ( ( ) => _provider . Create ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
75+ Assert . That ( ( ) => _provider . IoCConstruct ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
7676 }
7777
7878 [ Test ]
7979 public void GetSingletonReturnsSingletonIfTypeRegisteredAsSingleton ( )
8080 {
8181 var builder = new ContainerBuilder ( ) ;
8282 builder . Register ( c => new object ( ) ) . SingleInstance ( ) ;
83- builder . Update ( container ) ;
83+ builder . Update ( _container ) ;
8484
85- Assert . That ( provider . GetSingleton < object > ( ) , Is . TypeOf < object > ( ) ) ;
86- Assert . That ( provider . GetSingleton < object > ( ) , Is . SameAs ( provider . GetSingleton < object > ( ) ) ) ;
85+ Assert . That ( _provider . GetSingleton < object > ( ) , Is . TypeOf < object > ( ) ) ;
86+ Assert . That ( _provider . GetSingleton < object > ( ) , Is . SameAs ( _provider . GetSingleton < object > ( ) ) ) ;
8787 }
8888
8989 [ Test ]
9090 public void GetSingletonThrowsDependencyResolutionExceptionIfTypeRegisteredButNotAsSingleton ( )
9191 {
9292 var builder = new ContainerBuilder ( ) ;
9393 builder . Register ( c => new object ( ) ) ;
94- builder . Update ( container ) ;
94+ builder . Update ( _container ) ;
9595
96- Assert . That ( ( ) => provider . GetSingleton < object > ( ) , Throws . TypeOf < DependencyResolutionException > ( ) ) ;
96+ Assert . That ( ( ) => _provider . GetSingleton < object > ( ) , Throws . TypeOf < DependencyResolutionException > ( ) ) ;
9797 }
9898
9999 [ Test ]
100100 public void GetSingletonThrowsComponentNotRegisteredExceptionWhenNoTypeRegistered ( )
101101 {
102- Assert . That ( ( ) => provider . GetSingleton < object > ( ) , Throws . TypeOf < ComponentNotRegisteredException > ( ) ) ;
102+ Assert . That ( ( ) => _provider . GetSingleton < object > ( ) , Throws . TypeOf < ComponentNotRegisteredException > ( ) ) ;
103103 }
104104
105105 [ Test ]
106106 public void GetSingletonThrowsArgumentNullExceptionWhenCalledWithNoTypeArgument ( )
107107 {
108- Assert . That ( ( ) => provider . GetSingleton ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
108+ Assert . That ( ( ) => _provider . GetSingleton ( null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
109109 }
110110
111111 [ Test ]
112112 public void TryResolveResolvesOutParameterWhenMatchingTypeRegistered ( )
113113 {
114114 var builder = new ContainerBuilder ( ) ;
115115 builder . Register ( c => new object ( ) ) ;
116- builder . Update ( container ) ;
116+ builder . Update ( _container ) ;
117117
118- object foo = null ;
119- var success = false ;
118+ object foo ;
119+ var success = _provider . TryResolve ( out foo ) ;
120120
121- success = provider . TryResolve < object > ( out foo ) ;
122121 Assert . That ( foo , Is . TypeOf < object > ( ) ) ;
123122 Assert . That ( success , Is . True ) ;
124123 }
125124
126125 [ Test ]
127126 public void RegisterTypeRegistersConcreteTypeAgainstInterface ( )
128127 {
129- provider . RegisterType < Interface , Concrete > ( ) ;
130- var instance = provider . Resolve < Interface > ( ) ;
128+ _provider . RegisterType < IInterface , Concrete > ( ) ;
129+ var instance = _provider . Resolve < IInterface > ( ) ;
131130 Assert . That ( instance , Is . TypeOf < Concrete > ( ) ) ;
132- Assert . That ( instance , Is . Not . SameAs ( provider . Resolve < Interface > ( ) ) ) ;
131+ Assert . That ( instance , Is . Not . SameAs ( _provider . Resolve < IInterface > ( ) ) ) ;
133132 }
134133
135134 [ Test ]
136135 public void RegisterTypeWithDelegateRegistersConcreteTypeAgainstInterface ( )
137136 {
138- provider . RegisterType < Interface > ( ( ) => new Concrete ( ) ) ;
139- var instance = provider . Resolve < Interface > ( ) ;
137+ _provider . RegisterType < IInterface > ( ( ) => new Concrete ( ) ) ;
138+ var instance = _provider . Resolve < IInterface > ( ) ;
140139 Assert . That ( instance , Is . TypeOf < Concrete > ( ) ) ;
141- Assert . That ( instance , Is . Not . SameAs ( provider . Resolve < Interface > ( ) ) ) ;
140+ Assert . That ( instance , Is . Not . SameAs ( _provider . Resolve < IInterface > ( ) ) ) ;
142141
143- provider . RegisterType ( typeof ( Interface ) , ( ) => new Concrete ( ) ) ;
144- Assert . That ( provider . Resolve < Interface > ( ) , Is . Not . SameAs ( provider . Resolve < Interface > ( ) ) ) ;
142+ _provider . RegisterType ( typeof ( IInterface ) , ( ) => new Concrete ( ) ) ;
143+ Assert . That ( _provider . Resolve < IInterface > ( ) , Is . Not . SameAs ( _provider . Resolve < IInterface > ( ) ) ) ;
145144 }
146145
147146 [ Test ]
148147 public void RegisterTypeWithDelegateAndTypeParameterRegistersConcreteTypeAgainstInterface ( )
149148 {
150- provider . RegisterType ( typeof ( Interface ) , ( ) => new Concrete ( ) ) ;
151- var instance = provider . Resolve < Interface > ( ) ;
149+ _provider . RegisterType ( typeof ( IInterface ) , ( ) => new Concrete ( ) ) ;
150+ var instance = _provider . Resolve < IInterface > ( ) ;
152151 Assert . That ( instance , Is . TypeOf < Concrete > ( ) ) ;
153- Assert . That ( instance , Is . Not . SameAs ( provider . Resolve < Interface > ( ) ) ) ;
152+ Assert . That ( instance , Is . Not . SameAs ( _provider . Resolve < IInterface > ( ) ) ) ;
154153 }
155154
156155 [ Test ]
157156 public void RegisterTypeThrowsArgumentNullExceptionWhenCalledWithNoFromOrToTypeArgument ( )
158157 {
159- Assert . That ( ( ) => provider . RegisterType ( null , typeof ( object ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
160- Assert . That ( ( ) => provider . RegisterType ( typeof ( object ) , ( Type ) null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
158+ Assert . That ( ( ) => _provider . RegisterType ( null , typeof ( object ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
159+ Assert . That ( ( ) => _provider . RegisterType ( typeof ( object ) , ( Type ) null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
161160 }
162161
163162 [ Test ]
164163 public void RegisterTypeThrowsArgumentNullExceptionWhenCalledWithNoTypeInstanceOrConstructorArgument ( )
165164 {
166- Assert . That ( ( ) => provider . RegisterType ( ( Func < object > ) null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
167- Assert . That ( ( ) => provider . RegisterType ( null , ( ) => new object ( ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
168- Assert . That ( ( ) => provider . RegisterType ( typeof ( object ) , ( Func < object > ) null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
165+ Assert . That ( ( ) => _provider . RegisterType ( ( Func < object > ) null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
166+ Assert . That ( ( ) => _provider . RegisterType ( null , ( ) => new object ( ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
167+ Assert . That ( ( ) => _provider . RegisterType ( typeof ( object ) , ( Func < object > ) null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
169168 }
170169
171170 [ Test ]
172171 public void RegisterSingletonRegistersConcreteTypeAsSingletonAgainstInterface ( )
173172 {
174173 var concreteViaFunc = new Concrete ( ) ;
175- provider . RegisterSingleton < Interface > ( ( ) => concreteViaFunc ) ;
176- Assert . That ( provider . Resolve < Interface > ( ) , Is . EqualTo ( concreteViaFunc ) ) ;
177- Assert . That ( provider . Resolve < Interface > ( ) , Is . SameAs ( provider . Resolve < Interface > ( ) ) ) ;
174+ _provider . RegisterSingleton < IInterface > ( ( ) => concreteViaFunc ) ;
175+ Assert . That ( _provider . Resolve < IInterface > ( ) , Is . EqualTo ( concreteViaFunc ) ) ;
176+ Assert . That ( _provider . Resolve < IInterface > ( ) , Is . SameAs ( _provider . Resolve < IInterface > ( ) ) ) ;
178177
179178 var concreteInstance = new Concrete ( ) ;
180- provider . RegisterSingleton < Interface > ( concreteInstance ) ;
181- Assert . That ( provider . Resolve < Interface > ( ) , Is . EqualTo ( concreteInstance ) ) ;
182- Assert . That ( provider . Resolve < Interface > ( ) , Is . SameAs ( provider . Resolve < Interface > ( ) ) ) ;
179+ _provider . RegisterSingleton < IInterface > ( concreteInstance ) ;
180+ Assert . That ( _provider . Resolve < IInterface > ( ) , Is . EqualTo ( concreteInstance ) ) ;
181+ Assert . That ( _provider . Resolve < IInterface > ( ) , Is . SameAs ( _provider . Resolve < IInterface > ( ) ) ) ;
183182 }
184183
185184 [ Test ]
186185 public void RegisterSingletoneThrowsArgumentNullExceptionWhenCalledWithNoTypeInstanceOrConstructorArgument ( )
187186 {
188- Interface nullInterface = null ;
189- Func < Interface > nullConstructor = null ;
190- Assert . That ( ( ) => provider . RegisterSingleton < Interface > ( nullInterface ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
191- Assert . That ( ( ) => provider . RegisterSingleton < Interface > ( nullConstructor ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
192- Assert . That ( ( ) => provider . RegisterSingleton ( null , new object ( ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
193- Assert . That ( ( ) => provider . RegisterSingleton ( null , ( ) => new object ( ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
194- Assert . That ( ( ) => provider . RegisterSingleton ( typeof ( object ) , null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
195- Assert . That ( ( ) => provider . RegisterSingleton ( typeof ( object ) , nullConstructor ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
187+ Assert . That ( ( ) => _provider . RegisterSingleton ( ( IInterface ) null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
188+ Assert . That ( ( ) => _provider . RegisterSingleton ( ( Func < IInterface > ) null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
189+ Assert . That ( ( ) => _provider . RegisterSingleton ( null , new object ( ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
190+ Assert . That ( ( ) => _provider . RegisterSingleton ( null , ( ) => new object ( ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
191+ Assert . That ( ( ) => _provider . RegisterSingleton ( typeof ( object ) , null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
196192 }
197193
198194 [ Test ]
199195 public void CallbackWhenRegisteredFiresSuccessfully ( )
200196 {
201197 var called = false ;
202- provider . CallbackWhenRegistered < Interface > ( ( ) => called = true ) ;
198+ _provider . CallbackWhenRegistered < IInterface > ( ( ) => called = true ) ;
203199
204- provider . RegisterType < Interface , Concrete > ( ) ;
200+ _provider . RegisterType < IInterface , Concrete > ( ) ;
205201 Assert . That ( called , Is . True ) ;
206202 }
207203
208204 [ Test ]
209205 public void CallbackWhenRegisteredThrowsArgumentNullExceptionWhenCalledWithNoTypeOrActionArgument ( )
210206 {
211- Assert . That ( ( ) => provider . CallbackWhenRegistered ( null , ( ) => new object ( ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
212- Assert . That ( ( ) => provider . CallbackWhenRegistered ( typeof ( object ) , null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
207+ Assert . That ( ( ) => _provider . CallbackWhenRegistered ( null , ( ) => new object ( ) ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
208+ Assert . That ( ( ) => _provider . CallbackWhenRegistered ( typeof ( object ) , null ) , Throws . TypeOf < ArgumentNullException > ( ) ) ;
213209 }
214210
215- private interface Interface
211+ private interface IInterface
216212 {
217213 }
218214
219- private class Concrete : Interface
215+ private class Concrete : IInterface
220216 {
221217 }
222218 }
0 commit comments