@@ -20,12 +20,12 @@ public class AutoFakeIt
2020 /// <returns>A class with all its dependencies faked.</returns>
2121 /// <exception cref="ArgumentException">Throws an ArgumentException if we can't find a public constructor
2222 /// with "fakeable" dependencies.</exception>
23- public T Generate < T > ( ) where T : class => ( T ) Generate ( typeof ( T ) ) ;
23+ public T Generate < T > ( ) where T : notnull => ( T ) Generate ( typeof ( T ) ) ;
2424
2525 /// <summary>
26- /// Generates a object automatically injecting FakeItEasy's fakes for all its dependencies.
26+ /// Generates an object of the specified type automatically injecting FakeItEasy's fakes for all its dependencies.
2727 /// </summary>
28- /// <param name="type">The class you want to generate, usually your System Under Test.</param>
28+ /// <param name="type">The type of the class you want to generate, usually your System Under Test.</param>
2929 /// <returns>A class with all its dependencies faked.</returns>
3030 /// <exception cref="ArgumentException">Throws an ArgumentException if we can't find a public constructor
3131 /// with "fakeable" dependencies.</exception>
@@ -87,27 +87,22 @@ private void InsertMissingFakedObjects(Dictionary<Type, object> candidateFakeObj
8787 /// </summary>
8888 /// <typeparam name="T">The fake object you want to retrieve.</typeparam>
8989 /// <returns>An object of the given type, either previously provided or a new one just generated with FakeItEasy.</returns>
90- public T Resolve < T > ( ) where T : notnull
91- {
92- if ( _fakedObjects . ContainsKey ( typeof ( T ) ) )
93- return ( T ) _fakedObjects [ typeof ( T ) ] ;
94-
95- _fakedObjects [ typeof ( T ) ] = A . Fake < T > ( ) ;
96- return ( T ) _fakedObjects [ typeof ( T ) ] ;
97- }
90+ public T Resolve < T > ( ) where T : notnull => ( T ) Resolve ( typeof ( T ) ) ;
9891
9992 /// <summary>
100- /// Returns the object used for <param name=" type" /> . If an object of the given type was not explicitly
93+ /// Returns the object used for the type passed . If an object of the given type was not explicitly
10194 /// provided, it will create a FakeItEasy's fake that will be used for all subsequent calls.
10295 /// </summary>
10396 /// <returns>An object of the given type, either previously provided or a new one just generated with FakeItEasy.</returns>
10497 public object Resolve ( Type type )
10598 {
10699 if ( _fakedObjects . ContainsKey ( type ) )
107100 return _fakedObjects [ type ] ;
108-
109- _fakedObjects [ type ] = Create . Fake ( type ) ;
110- return _fakedObjects [ type ] ;
101+ else
102+ {
103+ _fakedObjects [ type ] = Create . Fake ( type ) ;
104+ return _fakedObjects [ type ] ;
105+ }
111106 }
112107
113108
@@ -127,6 +122,7 @@ public object Resolve(Type type)
127122 /// <see cref="Resolve"/> or for a dependency on <see cref="Generate"/>. </summary>
128123 /// <remarks><para>This is useful for providing your own specific instance of a type, either because you can't
129124 /// use an automatically generated fake, or because you have a concrete type that you prefer to use.</para>
125+ /// <param name="registerType">The type of the object you want to provide.</param>
130126 /// <param name="dependency">The object you want to set.</param>
131127 /// <para>It will override any previously registered object of the same type of <param name="registerType"/>.</para></remarks>
132128 /// <exception cref="ArgumentException">Throws an ArgumentException if dependency is not assignable to registerType.</exception>
0 commit comments