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 ;
@@ -123,8 +124,9 @@ private object CreateInstanceOfType(Type type, ObjectFillerSetup currentSetup)
123
124
124
125
if ( constructorArgs . Count == 0 )
125
126
{
126
- throw new InvalidOperationException ( "Could not found a constructor for type [" + type . Name +
127
- "] where the parameters can be filled with the current objectfiller setup" ) ;
127
+ var message = "Could not found a constructor for type [" + type . Name + "] where the parameters can be filled with the current objectfiller setup" ;
128
+ Debug . WriteLine ( "ObjectFiller: " + message ) ;
129
+ throw new InvalidOperationException ( message ) ;
128
130
}
129
131
}
130
132
}
@@ -316,13 +318,12 @@ private IDictionary GetFilledDictionary(Type propertyType, ObjectFillerSetup cur
316
318
317
319
if ( dictionary . Contains ( keyObject ) )
318
320
{
319
- throw new ArgumentException (
320
- string . Format (
321
- "Generating Keyvalue failed because it generates always the same data for type [{0}]. Please check your setup." ,
322
- keyType ) ) ;
321
+ string message = string . Format ( "Generating Keyvalue failed because it generates always the same data for type [{0}]. Please check your setup." , keyType ) ;
322
+ Debug . WriteLine ( "ObjectFiller: " + message ) ;
323
+ throw new ArgumentException ( message ) ;
323
324
}
324
325
325
- object valueObject = GetFilledObject ( valueType , currentSetup ) ;
326
+ object valueObject = GetFilledObject ( valueType , currentSetup ) ;
326
327
dictionary . Add ( keyObject , valueObject ) ;
327
328
}
328
329
return dictionary ;
@@ -382,12 +383,12 @@ private object GetInterfaceInstance(Type interfaceType, ObjectFillerSetup setup)
382
383
{
383
384
if ( setup . InterfaceMocker == null )
384
385
{
385
- throw new InvalidOperationException (
386
- string . Format ( "ObjectFiller Interface mocker missing and type [{0}] not registered" ,
387
- interfaceType . Name ) ) ;
386
+ string message = string . Format ( "ObjectFiller Interface mocker missing and type [{0}] not registered" , interfaceType . Name ) ;
387
+ Debug . WriteLine ( "ObjectFiller: " + message ) ;
388
+ throw new InvalidOperationException ( message ) ;
388
389
}
389
390
390
- MethodInfo method = setup . InterfaceMocker . GetType ( ) . GetMethod ( "Create" ) ;
391
+ MethodInfo method = setup . InterfaceMocker . GetType ( ) . GetMethod ( "Create" ) ;
391
392
MethodInfo genericMethod = method . MakeGenericMethod ( new [ ] { interfaceType } ) ;
392
393
result = genericMethod . Invoke ( setup . InterfaceMocker , null ) ;
393
394
}
@@ -402,7 +403,9 @@ private object GetRandomValue(Type propertyType, ObjectFillerSetup setup)
402
403
return setup . TypeToRandomFunc [ propertyType ] ( ) ;
403
404
}
404
405
405
- throw new TypeInitializationException ( propertyType . FullName , new Exception ( "The type [" + propertyType . Name + "] was not registered in the randomizer." ) ) ;
406
+ string message = "The type [" + propertyType . Name + "] was not registered in the randomizer." ;
407
+ Debug . WriteLine ( "ObjectFiller: " + message ) ;
408
+ throw new TypeInitializationException ( propertyType . FullName , new Exception ( message ) ) ;
406
409
}
407
410
408
411
private static bool TypeIsValidForObjectFiller ( Type type , ObjectFillerSetup currentSetup )
0 commit comments