2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
4
using System . Configuration ;
5
+ using System . Diagnostics ;
5
6
using System . Globalization ;
6
7
using System . Linq ;
7
8
using System . Reflection ;
@@ -109,8 +110,9 @@ private object CreateInstanceOfType(Type type, ObjectFillerSetup currentSetup)
109
110
110
111
if ( constructorArgs . Count == 0 )
111
112
{
112
- throw new InvalidOperationException ( "Could not found a constructor for type [" + type . Name +
113
- "] where the parameters can be filled with the current objectfiller setup" ) ;
113
+ var message = "Could not found a constructor for type [" + type . Name + "] where the parameters can be filled with the current objectfiller setup" ;
114
+ Debug . WriteLine ( "ObjectFiller: " + message ) ;
115
+ throw new InvalidOperationException ( message ) ;
114
116
}
115
117
}
116
118
}
@@ -302,13 +304,12 @@ private IDictionary GetFilledDictionary(Type propertyType, ObjectFillerSetup cur
302
304
303
305
if ( dictionary . Contains ( keyObject ) )
304
306
{
305
- throw new ArgumentException (
306
- string . Format (
307
- "Generating Keyvalue failed because it generates always the same data for type [{0}]. Please check your setup." ,
308
- keyType ) ) ;
307
+ string message = string . Format ( "Generating Keyvalue failed because it generates always the same data for type [{0}]. Please check your setup." , keyType ) ;
308
+ Debug . WriteLine ( "ObjectFiller: " + message ) ;
309
+ throw new ArgumentException ( message ) ;
309
310
}
310
311
311
- object valueObject = GetFilledObject ( valueType , currentSetup ) ;
312
+ object valueObject = GetFilledObject ( valueType , currentSetup ) ;
312
313
dictionary . Add ( keyObject , valueObject ) ;
313
314
}
314
315
return dictionary ;
@@ -368,12 +369,12 @@ private object GetInterfaceInstance(Type interfaceType, ObjectFillerSetup setup)
368
369
{
369
370
if ( setup . InterfaceMocker == null )
370
371
{
371
- throw new InvalidOperationException (
372
- string . Format ( "ObjectFiller Interface mocker missing and type [{0}] not registered" ,
373
- interfaceType . Name ) ) ;
372
+ string message = string . Format ( "ObjectFiller Interface mocker missing and type [{0}] not registered" , interfaceType . Name ) ;
373
+ Debug . WriteLine ( "ObjectFiller: " + message ) ;
374
+ throw new InvalidOperationException ( message ) ;
374
375
}
375
376
376
- MethodInfo method = setup . InterfaceMocker . GetType ( ) . GetMethod ( "Create" ) ;
377
+ MethodInfo method = setup . InterfaceMocker . GetType ( ) . GetMethod ( "Create" ) ;
377
378
MethodInfo genericMethod = method . MakeGenericMethod ( new [ ] { interfaceType } ) ;
378
379
result = genericMethod . Invoke ( setup . InterfaceMocker , null ) ;
379
380
}
@@ -388,7 +389,9 @@ private object GetRandomValue(Type propertyType, ObjectFillerSetup setup)
388
389
return setup . TypeToRandomFunc [ propertyType ] ( ) ;
389
390
}
390
391
391
- throw new TypeInitializationException ( propertyType . FullName , new Exception ( "The type [" + propertyType . Name + "] was not registered in the randomizer." ) ) ;
392
+ string message = "The type [" + propertyType . Name + "] was not registered in the randomizer." ;
393
+ Debug . WriteLine ( "ObjectFiller: " + message ) ;
394
+ throw new TypeInitializationException ( propertyType . FullName , new Exception ( message ) ) ;
392
395
}
393
396
394
397
private static bool TypeIsValidForObjectFiller ( Type type , ObjectFillerSetup currentSetup )
0 commit comments