@@ -55,7 +55,7 @@ public FluentFillerApi<T> Setup(FillerSetup fillerSetupToUse)
55
55
/// </summary>
56
56
public T Create ( )
57
57
{
58
- T objectToFill = ( T ) CreateInstanceOfType ( typeof ( T ) , _setupManager . GetFor < T > ( ) ) ;
58
+ T objectToFill = ( T ) CreateInstanceOfType ( typeof ( T ) , _setupManager . GetFor < T > ( ) , new HashStack < Type > ( ) ) ;
59
59
60
60
Fill ( objectToFill ) ;
61
61
@@ -68,9 +68,10 @@ public T Create()
68
68
/// </summary>
69
69
public IEnumerable < T > Create ( int count )
70
70
{
71
+ var typeStack = new HashStack < Type > ( ) ;
71
72
for ( int n = 0 ; n < count ; n ++ )
72
73
{
73
- T objectToFill = ( T ) CreateInstanceOfType ( typeof ( T ) , _setupManager . GetFor < T > ( ) ) ;
74
+ T objectToFill = ( T ) CreateInstanceOfType ( typeof ( T ) , _setupManager . GetFor < T > ( ) , typeStack ) ;
74
75
Fill ( objectToFill ) ;
75
76
yield return objectToFill ;
76
77
}
@@ -87,7 +88,7 @@ public T Fill(T instanceToFill)
87
88
}
88
89
89
90
90
- private object CreateInstanceOfType ( Type type , FillerSetupItem currentSetupItem )
91
+ private object CreateInstanceOfType ( Type type , FillerSetupItem currentSetupItem , HashStack < Type > typeTracker )
91
92
{
92
93
List < object > constructorArgs = new List < object > ( ) ;
93
94
@@ -104,7 +105,7 @@ private object CreateInstanceOfType(Type type, FillerSetupItem currentSetupItem)
104
105
{
105
106
foreach ( Type paramType in paramTypes )
106
107
{
107
- constructorArgs . Add ( GetFilledObject ( paramType , currentSetupItem ) ) ;
108
+ constructorArgs . Add ( GetFilledObject ( paramType , currentSetupItem , typeTracker ) ) ;
108
109
}
109
110
110
111
break ;
@@ -313,7 +314,7 @@ private object GetFilledPoco(Type type, FillerSetupItem currentSetupItem, HashSt
313
314
}
314
315
typeTracker . Push ( type ) ;
315
316
316
- object result = CreateInstanceOfType ( type , currentSetupItem ) ;
317
+ object result = CreateInstanceOfType ( type , currentSetupItem , typeTracker ) ;
317
318
318
319
FillInternal ( result , typeTracker ) ;
319
320
@@ -404,7 +405,7 @@ private object CreateInstanceOfInterfaceOrAbstractClass(Type interfaceType, Fill
404
405
if ( setupItem . InterfaceToImplementation . ContainsKey ( interfaceType ) )
405
406
{
406
407
Type implType = setupItem . InterfaceToImplementation [ interfaceType ] ;
407
- result = CreateInstanceOfType ( implType , setupItem ) ;
408
+ result = CreateInstanceOfType ( implType , setupItem , typeTracker ) ;
408
409
}
409
410
else
410
411
{
0 commit comments