From 720a5feb4c6df753e83ad5a1a1c44bf6f28fe206 Mon Sep 17 00:00:00 2001 From: gokTyBalD Date: Tue, 5 Aug 2014 20:33:32 +0200 Subject: [PATCH] FillerSetup can now be exported and reused for the next time --- ObjectFiller.Test/ObjectFiller.Test.csproj | 1 + ObjectFiller.Test/SaveFillerSetupTest.cs | 77 ++++++++++ ObjectFiller/Filler.cs | 145 ++++++++---------- ObjectFiller/ObjectFiller.csproj | 3 +- ObjectFiller/Setup/FillerSetup.cs | 17 ++ ...bjectFillerSetup.cs => FillerSetupItem.cs} | 26 ++-- ObjectFiller/Setup/FluentFillerApi.cs | 15 +- ObjectFiller/Setup/SetupManager.cs | 54 +++---- 8 files changed, 204 insertions(+), 134 deletions(-) create mode 100644 ObjectFiller.Test/SaveFillerSetupTest.cs create mode 100644 ObjectFiller/Setup/FillerSetup.cs rename ObjectFiller/Setup/{ObjectFillerSetup.cs => FillerSetupItem.cs} (80%) diff --git a/ObjectFiller.Test/ObjectFiller.Test.csproj b/ObjectFiller.Test/ObjectFiller.Test.csproj index c9fa1aa..e9e5ba4 100644 --- a/ObjectFiller.Test/ObjectFiller.Test.csproj +++ b/ObjectFiller.Test/ObjectFiller.Test.csproj @@ -73,6 +73,7 @@ + diff --git a/ObjectFiller.Test/SaveFillerSetupTest.cs b/ObjectFiller.Test/SaveFillerSetupTest.cs new file mode 100644 index 0000000..64513d0 --- /dev/null +++ b/ObjectFiller.Test/SaveFillerSetupTest.cs @@ -0,0 +1,77 @@ +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using ObjectFiller.Test.TestPoco.Person; +using Tynamix.ObjectFiller; + +namespace ObjectFiller.Test +{ + [TestClass] + public class SaveFillerSetupTest + { + private FillerSetup _fillerSetup; + + [TestInitialize] + public void GetFillerSetup() + { + + Filler filler = new Filler(); + _fillerSetup = filler.Setup() + .OnType().CreateInstanceOf
() + .OnProperty(x => x.Age).Use(new IntRange(18, 35)) + .OnProperty(x => x.FirstName).Use(new RealNames(RealNameStyle.FirstNameOnly)) + .OnProperty(x => x.LastName).Use(new RealNames(RealNameStyle.LastNameOnly)) + .SetupFor
() + .OnProperty(x => x.HouseNumber).Use(new IntRange(1, 100)) + .Result; + + } + + [TestMethod] + public void UseSavedFillerDefaultSetup() + { + Filler filler = new Filler(); + filler.Setup(_fillerSetup); + + Person p = filler.Create(); + + Assert.IsTrue(p.Age < 35 && p.Age >= 18); + Assert.IsTrue(p.Address.HouseNumber < 100 && p.Age >= 1); + } + + + [TestMethod] + public void UseSavedFillerSetupWithExtensions() + { + var dateNow = DateTime.Now; + Filler filler = new Filler(); + filler.Setup(_fillerSetup) + .OnProperty(x => x.Birthdate).Use(() => dateNow); + + Person p = filler.Create(); + + Assert.IsTrue(p.Age < 35 && p.Age >= 18); + Assert.IsTrue(p.Address.HouseNumber < 100 && p.Age >= 1); + Assert.AreEqual(p.Birthdate, dateNow); + + } + + [TestMethod] + public void UseSavedFillerSetupWithOverrides() + { + Filler filler = new Filler(); + filler.Setup(_fillerSetup) + .OnProperty(x => x.Age).Use(() => 1000) + .SetupFor
() + .OnProperty(x => x.HouseNumber).Use(() => 9999); + + Person p = filler.Create(); + + Assert.AreEqual(p.Age, 1000); + Assert.AreEqual(p.Address.HouseNumber, 9999); + + } + + + + } +} diff --git a/ObjectFiller/Filler.cs b/ObjectFiller/Filler.cs index 105097e..29db437 100644 --- a/ObjectFiller/Filler.cs +++ b/ObjectFiller/Filler.cs @@ -22,8 +22,6 @@ public class Filler where T : class public Filler() { _setupManager = new SetupManager(); - - _setupManager.Clear(); } /// @@ -32,20 +30,23 @@ public Filler() /// Fluent API setup public FluentFillerApi Setup() { - return new FluentFillerApi(_setupManager); + return Setup(null); } - /// - /// This will create your object of type and overrides the setup for the generation. - /// Use this method if you don't wan't to use the FluentAPI + /// Call this to start the setup for the and use a setup which you created + /// before with the FluentApi /// - /// Setup for the objectfiller - /// Object which is filled with random data - public T Create(ObjectFillerSetup setup) + /// FillerSetup to use + /// Fluebt API Setup + public FluentFillerApi Setup(FillerSetup fillerSetupToUse) { - _setupManager.SetMain(setup); - return Create(); + if (fillerSetupToUse != null) + { + _setupManager.FillerSetup = fillerSetupToUse; + } + return new FluentFillerApi(_setupManager); + } /// @@ -75,20 +76,6 @@ public IEnumerable Create(int count) } } - /// - /// This will fill your instance of an object of type and overrides the setup for the generation. - /// Use this method if you don't wan't to use the FluentAPI - /// - /// The instance which will get filled with random data. - /// Setup for the objectfiller - /// Instance which is filled with random data - public T Fill(T instanceToFill, ObjectFillerSetup setup) - { - _setupManager.SetMain(setup); - return Create(); - } - - /// /// Fills your object instance. Call this after you finished your setup with the FluentAPI /// @@ -100,7 +87,7 @@ public T Fill(T instanceToFill) } - private object CreateInstanceOfType(Type type, ObjectFillerSetup currentSetup) + private object CreateInstanceOfType(Type type, FillerSetupItem currentSetupItem) { List constructorArgs = new List(); @@ -113,11 +100,11 @@ private object CreateInstanceOfType(Type type, ObjectFillerSetup currentSetup) { Type[] paramTypes = ctorInfo.GetParameters().Select(p => p.ParameterType).ToArray(); - if (paramTypes.All(t => TypeIsValidForObjectFiller(t, currentSetup))) + if (paramTypes.All(t => TypeIsValidForObjectFiller(t, currentSetupItem))) { foreach (Type paramType in paramTypes) { - constructorArgs.Add(GetFilledObject(paramType, currentSetup)); + constructorArgs.Add(GetFilledObject(paramType, currentSetupItem)); } break; @@ -142,7 +129,7 @@ private void FillInternal(object objectToFill, HashStack typeTracker = nul { var currentSetup = _setupManager.GetFor(objectToFill.GetType()); var targetType = objectToFill.GetType(); - + typeTracker = typeTracker ?? new HashStack(); if (currentSetup.TypeToRandomFunc.ContainsKey(targetType)) @@ -196,18 +183,18 @@ private void SetPropertyValue(PropertyInfo property, object objectToFill, object } } - private Queue OrderPropertiers(ObjectFillerSetup currentSetup, PropertyInfo[] properties) + private Queue OrderPropertiers(FillerSetupItem currentSetupItem, PropertyInfo[] properties) { Queue propertyQueue = new Queue(); - var firstProperties = currentSetup.PropertyOrder + var firstProperties = currentSetupItem.PropertyOrder .Where(x => x.Value == At.TheBegin && ContainsProperty(properties, x.Key)) .Select(x => x.Key).ToList(); - var lastProperties = currentSetup.PropertyOrder + var lastProperties = currentSetupItem.PropertyOrder .Where(x => x.Value == At.TheEnd && ContainsProperty(properties, x.Key)) .Select(x => x.Key).ToList(); - var propertiesWithoutOrder = properties.Where(x => !ContainsProperty(currentSetup.PropertyOrder.Keys, x)).ToList(); + var propertiesWithoutOrder = properties.Where(x => !ContainsProperty(currentSetupItem.PropertyOrder.Keys, x)).ToList(); firstProperties.ForEach(propertyQueue.Enqueue); @@ -217,9 +204,9 @@ private Queue OrderPropertiers(ObjectFillerSetup currentSetup, Pro return propertyQueue; } - private bool IgnoreProperty(PropertyInfo property, ObjectFillerSetup currentSetup) + private bool IgnoreProperty(PropertyInfo property, FillerSetupItem currentSetupItem) { - return ContainsProperty(currentSetup.PropertiesToIgnore, property); + return ContainsProperty(currentSetupItem.PropertiesToIgnore, property); } private bool ContainsProperty(IEnumerable properties, PropertyInfo property) @@ -246,34 +233,34 @@ private IEnumerable GetPropertyFromProperties(IEnumerable x.MetadataToken == property.MetadataToken && x.Module.Equals(property.Module)); } - private object GetFilledObject(Type type, ObjectFillerSetup currentSetup, HashStack typeTracker = null) + private object GetFilledObject(Type type, FillerSetupItem currentSetupItem, HashStack typeTracker = null) { - if (HasTypeARandomFunc(type, currentSetup)) + if (HasTypeARandomFunc(type, currentSetupItem)) { - return GetRandomValue(type, currentSetup); + return GetRandomValue(type, currentSetupItem); } if (TypeIsDictionary(type)) { - IDictionary dictionary = GetFilledDictionary(type, currentSetup); + IDictionary dictionary = GetFilledDictionary(type, currentSetupItem); return dictionary; } if (TypeIsList(type)) { - IList list = GetFilledList(type, currentSetup); + IList list = GetFilledList(type, currentSetupItem); return list; } if (type.IsInterface) { - return GetInterfaceInstance(type, currentSetup); + return GetInterfaceInstance(type, currentSetupItem); } if (TypeIsPoco(type)) { - return GetFilledPoco(type, currentSetup, typeTracker); + return GetFilledPoco(type, currentSetupItem, typeTracker); } if (TypeIsEnum(type)) @@ -281,7 +268,7 @@ private object GetFilledObject(Type type, ObjectFillerSetup currentSetup, HashSt return GetRandomEnumValue(type); } - object newValue = GetRandomValue(type, currentSetup); + object newValue = GetRandomValue(type, currentSetupItem); return newValue; } @@ -297,7 +284,7 @@ private object GetRandomEnumValue(Type type) return 0; } - private object GetFilledPoco(Type type, ObjectFillerSetup currentSetup, HashStack typeTracker) + private object GetFilledPoco(Type type, FillerSetupItem currentSetupItem, HashStack typeTracker) { if (typeTracker != null) { @@ -312,7 +299,7 @@ private object GetFilledPoco(Type type, ObjectFillerSetup currentSetup, HashStac typeTracker.Push(type); } - object result = CreateInstanceOfType(type, currentSetup); + object result = CreateInstanceOfType(type, currentSetupItem); FillInternal(result, typeTracker); @@ -325,17 +312,17 @@ private object GetFilledPoco(Type type, ObjectFillerSetup currentSetup, HashStac return result; } - private IDictionary GetFilledDictionary(Type propertyType, ObjectFillerSetup currentSetup) + private IDictionary GetFilledDictionary(Type propertyType, FillerSetupItem currentSetupItem) { IDictionary dictionary = (IDictionary)Activator.CreateInstance(propertyType); Type keyType = propertyType.GetGenericArguments()[0]; Type valueType = propertyType.GetGenericArguments()[1]; - int maxDictionaryItems = Random.Next(currentSetup.DictionaryKeyMinCount, - currentSetup.DictionaryKeyMaxCount); + int maxDictionaryItems = Random.Next(currentSetupItem.DictionaryKeyMinCount, + currentSetupItem.DictionaryKeyMaxCount); for (int i = 0; i < maxDictionaryItems; i++) { - object keyObject = GetFilledObject(keyType, currentSetup); + object keyObject = GetFilledObject(keyType, currentSetupItem); if (dictionary.Contains(keyObject)) { @@ -344,19 +331,19 @@ private IDictionary GetFilledDictionary(Type propertyType, ObjectFillerSetup cur throw new ArgumentException(message); } - object valueObject = GetFilledObject(valueType, currentSetup); + object valueObject = GetFilledObject(valueType, currentSetupItem); dictionary.Add(keyObject, valueObject); } return dictionary; } - private static bool HasTypeARandomFunc(Type type, ObjectFillerSetup currentSetup) + private static bool HasTypeARandomFunc(Type type, FillerSetupItem currentSetupItem) { - return currentSetup.TypeToRandomFunc.ContainsKey(type); + return currentSetupItem.TypeToRandomFunc.ContainsKey(type); } - private IList GetFilledList(Type propertyType, ObjectFillerSetup currentSetup) + private IList GetFilledList(Type propertyType, FillerSetupItem currentSetupItem) { Type genType = propertyType.GetGenericArguments()[0]; @@ -379,52 +366,52 @@ private IList GetFilledList(Type propertyType, ObjectFillerSetup currentSetup) } - int maxListItems = Random.Next(currentSetup.ListMinCount, currentSetup.ListMaxCount); + int maxListItems = Random.Next(currentSetupItem.ListMinCount, currentSetupItem.ListMaxCount); for (int i = 0; i < maxListItems; i++) { - object listObject = GetFilledObject(genType, currentSetup); + object listObject = GetFilledObject(genType, currentSetupItem); list.Add(listObject); } return list; } - private object GetInterfaceInstance(Type interfaceType, ObjectFillerSetup setup) + private object GetInterfaceInstance(Type interfaceType, FillerSetupItem setupItem) { object result; - if (setup.TypeToRandomFunc.ContainsKey(interfaceType)) + if (setupItem.TypeToRandomFunc.ContainsKey(interfaceType)) { - return setup.TypeToRandomFunc[interfaceType](); + return setupItem.TypeToRandomFunc[interfaceType](); } - if (setup.InterfaceToImplementation.ContainsKey(interfaceType)) + if (setupItem.InterfaceToImplementation.ContainsKey(interfaceType)) { - Type implType = setup.InterfaceToImplementation[interfaceType]; - result = CreateInstanceOfType(implType, setup); + Type implType = setupItem.InterfaceToImplementation[interfaceType]; + result = CreateInstanceOfType(implType, setupItem); } else { - if (setup.InterfaceMocker == null) + if (setupItem.InterfaceMocker == null) { string message = string.Format("ObjectFiller Interface mocker missing and type [{0}] not registered", interfaceType.Name); Debug.WriteLine("ObjectFiller: " + message); throw new InvalidOperationException(message); } - MethodInfo method = setup.InterfaceMocker.GetType().GetMethod("Create"); + MethodInfo method = setupItem.InterfaceMocker.GetType().GetMethod("Create"); MethodInfo genericMethod = method.MakeGenericMethod(new[] { interfaceType }); - result = genericMethod.Invoke(setup.InterfaceMocker, null); + result = genericMethod.Invoke(setupItem.InterfaceMocker, null); } FillInternal(result); return result; } - private object GetRandomValue(Type propertyType, ObjectFillerSetup setup) + private object GetRandomValue(Type propertyType, FillerSetupItem setupItem) { - if (setup.TypeToRandomFunc.ContainsKey(propertyType)) + if (setupItem.TypeToRandomFunc.ContainsKey(propertyType)) { - return setup.TypeToRandomFunc[propertyType](); + return setupItem.TypeToRandomFunc[propertyType](); } - if (setup.IgnoreAllUnknownTypes) + if (setupItem.IgnoreAllUnknownTypes) { if (propertyType.IsValueType) { @@ -438,19 +425,19 @@ private object GetRandomValue(Type propertyType, ObjectFillerSetup setup) throw new TypeInitializationException(propertyType.FullName, new Exception(message)); } - private static bool TypeIsValidForObjectFiller(Type type, ObjectFillerSetup currentSetup) + private static bool TypeIsValidForObjectFiller(Type type, FillerSetupItem currentSetupItem) { - return HasTypeARandomFunc(type, currentSetup) - || (TypeIsList(type) && ListParamTypeIsValid(type, currentSetup)) - || (TypeIsDictionary(type) && DictionaryParamTypesAreValid(type, currentSetup)) + return HasTypeARandomFunc(type, currentSetupItem) + || (TypeIsList(type) && ListParamTypeIsValid(type, currentSetupItem)) + || (TypeIsDictionary(type) && DictionaryParamTypesAreValid(type, currentSetupItem)) || TypeIsPoco(type) || (type.IsInterface - && currentSetup.InterfaceToImplementation.ContainsKey(type) - || currentSetup.InterfaceMocker != null); + && currentSetupItem.InterfaceToImplementation.ContainsKey(type) + || currentSetupItem.InterfaceMocker != null); } - private static bool DictionaryParamTypesAreValid(Type type, ObjectFillerSetup currentSetup) + private static bool DictionaryParamTypesAreValid(Type type, FillerSetupItem currentSetupItem) { if (!TypeIsDictionary(type)) { @@ -460,11 +447,11 @@ private static bool DictionaryParamTypesAreValid(Type type, ObjectFillerSetup cu Type keyType = type.GetGenericArguments()[0]; Type valueType = type.GetGenericArguments()[1]; - return TypeIsValidForObjectFiller(keyType, currentSetup) && - TypeIsValidForObjectFiller(valueType, currentSetup); + return TypeIsValidForObjectFiller(keyType, currentSetupItem) && + TypeIsValidForObjectFiller(valueType, currentSetupItem); } - private static bool ListParamTypeIsValid(Type type, ObjectFillerSetup setup) + private static bool ListParamTypeIsValid(Type type, FillerSetupItem setupItem) { if (!TypeIsList(type)) { @@ -472,7 +459,7 @@ private static bool ListParamTypeIsValid(Type type, ObjectFillerSetup setup) } Type genType = type.GetGenericArguments()[0]; - return TypeIsValidForObjectFiller(genType, setup); + return TypeIsValidForObjectFiller(genType, setupItem); } private static bool TypeIsPoco(Type type) diff --git a/ObjectFiller/ObjectFiller.csproj b/ObjectFiller/ObjectFiller.csproj index 990827d..6d9605f 100644 --- a/ObjectFiller/ObjectFiller.csproj +++ b/ObjectFiller/ObjectFiller.csproj @@ -38,6 +38,7 @@ + @@ -62,7 +63,7 @@ True Resources.resx - + diff --git a/ObjectFiller/Setup/FillerSetup.cs b/ObjectFiller/Setup/FillerSetup.cs new file mode 100644 index 0000000..81d2c45 --- /dev/null +++ b/ObjectFiller/Setup/FillerSetup.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace Tynamix.ObjectFiller +{ + public class FillerSetup + { + public FillerSetup() + { + TypeToFillerSetup = new Dictionary(); + MainSetupItem = new FillerSetupItem(); + } + internal FillerSetupItem MainSetupItem { get; private set; } + + internal Dictionary TypeToFillerSetup { get; private set; } + } +} \ No newline at end of file diff --git a/ObjectFiller/Setup/ObjectFillerSetup.cs b/ObjectFiller/Setup/FillerSetupItem.cs similarity index 80% rename from ObjectFiller/Setup/ObjectFillerSetup.cs rename to ObjectFiller/Setup/FillerSetupItem.cs index 032db17..9f11c28 100644 --- a/ObjectFiller/Setup/ObjectFillerSetup.cs +++ b/ObjectFiller/Setup/FillerSetupItem.cs @@ -4,9 +4,9 @@ namespace Tynamix.ObjectFiller { - public class ObjectFillerSetup + internal class FillerSetupItem { - public ObjectFillerSetup() + internal FillerSetupItem() { ListMinCount = 1; ListMaxCount = 25; @@ -48,42 +48,42 @@ private void SetDefaultRandomizer() /// /// Defines in which order the properties get handled. /// - public Dictionary PropertyOrder { get; private set; } + internal Dictionary PropertyOrder { get; private set; } /// /// Contains the Type to random data generator func /// - public Dictionary> TypeToRandomFunc { get; private set; } + internal Dictionary> TypeToRandomFunc { get; private set; } /// /// Contains the Property to random data generator func /// - public Dictionary> PropertyToRandomFunc { get; private set; } + internal Dictionary> PropertyToRandomFunc { get; private set; } /// /// Contains the type of interface with the corresponding implementation /// - public Dictionary InterfaceToImplementation { get; private set; } + internal Dictionary InterfaceToImplementation { get; private set; } /// /// List with all properties which will be ignored while generating test data /// - public List PropertiesToIgnore { get; private set; } + internal List PropertiesToIgnore { get; private set; } /// /// All types which will be ignored completly /// - public List TypesToIgnore { get; private set; } + internal List TypesToIgnore { get; private set; } /// /// Minimum count of list items which will be generated /// - public int ListMinCount { get; set; } + internal int ListMinCount { get; set; } /// /// Maximum count of list items which will be generated /// - public int ListMaxCount { get; set; } + internal int ListMaxCount { get; set; } /// /// Minimum count of key items within a dictionary which will be generated @@ -93,17 +93,17 @@ private void SetDefaultRandomizer() /// /// Maximum count of key items within a dictionary which will be generated /// - public int DictionaryKeyMaxCount { get; set; } + internal int DictionaryKeyMaxCount { get; set; } /// /// Interface Mocker for interface generation /// - public IInterfaceMocker InterfaceMocker { get; set; } + internal IInterfaceMocker InterfaceMocker { get; set; } /// /// True if all unknown types will be ignored by the objectfiller /// - public bool IgnoreAllUnknownTypes { get; set; } + internal bool IgnoreAllUnknownTypes { get; set; } } } diff --git a/ObjectFiller/Setup/FluentFillerApi.cs b/ObjectFiller/Setup/FluentFillerApi.cs index 04525c0..ae15cad 100644 --- a/ObjectFiller/Setup/FluentFillerApi.cs +++ b/ObjectFiller/Setup/FluentFillerApi.cs @@ -20,6 +20,11 @@ internal FluentFillerApi(SetupManager setupManager) _setupManager = setupManager; } + public FillerSetup Result + { + get { return _setupManager.FillerSetup; } + } + /// /// Start to configure a type for objectfiller. The follow up methods will be found in the /// @@ -85,7 +90,7 @@ public FluentFillerApi IgnoreAllUnknownTypes() _setupManager.GetFor().IgnoreAllUnknownTypes = true; return this; - } + } /// /// Setup the minimum and maximum item count for lists. The ObjectFiller will not generate more or less listitems then this limits. @@ -134,11 +139,11 @@ public FluentFillerApi SetInterfaceMocker(IInterfaceMocker mocker { if (_setupManager.GetFor().InterfaceMocker != null) { - const string message = "You can not set a interface mocker more than once!"; - Debug.WriteLine("ObjectFiller: " + message); - throw new ArgumentException(message); + const string message = "You can not set a interface mocker more than once!"; + Debug.WriteLine("ObjectFiller: " + message); + throw new ArgumentException(message); } - _setupManager.GetFor().InterfaceMocker = mocker; + _setupManager.GetFor().InterfaceMocker = mocker; return this; } diff --git a/ObjectFiller/Setup/SetupManager.cs b/ObjectFiller/Setup/SetupManager.cs index 4e920bf..b7d7fac 100644 --- a/ObjectFiller/Setup/SetupManager.cs +++ b/ObjectFiller/Setup/SetupManager.cs @@ -4,74 +4,56 @@ namespace Tynamix.ObjectFiller { /// - /// Responsible to get the right for a given type. + /// Responsible to get the right for a given type. /// internal class SetupManager { - private ObjectFillerSetup _mainSetup; - private Dictionary _typeToSetup; + + internal FillerSetup FillerSetup { get; set; } /// /// static ctor /// internal SetupManager() { - Clear(); + FillerSetup = new FillerSetup(); } /// - /// Gets the for a given type + /// Gets the for a given type /// - /// Type for which a will be get - /// for type - internal ObjectFillerSetup GetFor() + /// Type for which a will be get + /// for type + internal FillerSetupItem GetFor() where TTargetObject : class { return GetFor(typeof(TTargetObject)); } /// - /// Gets the for a given type + /// Gets the for a given type /// - /// Type for which a will be get - /// for type - internal ObjectFillerSetup GetFor(Type targetType) + /// Type for which a will be get + /// for type + internal FillerSetupItem GetFor(Type targetType) { - if (_typeToSetup.ContainsKey(targetType)) + if (FillerSetup.TypeToFillerSetup.ContainsKey(targetType)) { - return _typeToSetup[targetType]; + return FillerSetup.TypeToFillerSetup[targetType]; } - return _mainSetup; + return FillerSetup.MainSetupItem; } /// - /// Sets a new for the given + /// Sets a new for the given /// - /// Type of target object for which a new will be set. + /// Type of target object for which a new will be set. /// FALSE if the target object will take the settings of the parent object internal void SetNewFor(bool useDefaultSettings) where TTargetObject : class { - _typeToSetup[typeof(TTargetObject)] = useDefaultSettings ? new ObjectFillerSetup() : _mainSetup; - } - - /// - /// Set the main . This will be the root setup. - /// - /// Main setup - internal void SetMain(ObjectFillerSetup setup) - { - _mainSetup = setup; - } - - /// - /// Clears all the settings which was made. - /// - internal void Clear() - { - _mainSetup = new ObjectFillerSetup(); - _typeToSetup = new Dictionary(); + FillerSetup.TypeToFillerSetup[typeof(TTargetObject)] = useDefaultSettings ? new FillerSetupItem() : FillerSetup.MainSetupItem; } } }