Skip to content

Commit 0fc675b

Browse files
gokTyBalDgokTyBalD
authored andcommitted
Documentation, deployment for 1.1.4
1 parent c246304 commit 0fc675b

File tree

8 files changed

+66
-19
lines changed

8 files changed

+66
-19
lines changed

ObjectFiller.Test/PersonFillingTest.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public void TestFirstNameAsConstantLastNameAsRealName()
6262
[TestMethod]
6363
public void GeneratePersonWithGivenSetOfNamesAndAges()
6464
{
65-
List<string> names = new List<string>() { "Tom", "Maik", "John", "Leo" };
66-
List<int> ages = new List<int>() { 10, 15, 18, 22, 26 };
65+
List<string> names = new List<string> { "Tom", "Maik", "John", "Leo" };
66+
List<int> ages = new List<int> { 10, 15, 18, 22, 26 };
6767

6868
ObjectFiller<Person> pFiller = new ObjectFiller<Person>();
6969
pFiller.Setup()
@@ -91,6 +91,11 @@ public void BigComplicated()
9191
.IgnoreProperties(a => a.Street);
9292

9393
var pF = pFiller.Fill();
94+
95+
Assert.IsNotNull(pF);
96+
Assert.IsNotNull(pF.Address);
97+
Assert.IsNull(pF.Address.Street);
98+
9499
}
95100

96101
[TestMethod]

ObjectFiller/IFluentFillerApi.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
namespace ObjectFiller
66
{
7+
/// <summary>
8+
/// Interface for the fluent API of the ObjectFiller.NET.
9+
/// </summary>
10+
/// <typeparam name="TTargetObject">Type of the object which will be configured</typeparam>
711
public interface IFluentFillerApi<TTargetObject>
812
where TTargetObject : class
913
{
1014
/// <summary>
1115
/// Sets the randomizer for the given type with a function delegate.
1216
/// This will then be the default way to generate data for the given <see cref="TTargetType"/>.
13-
/// When you want to change the randomizer of a specific propery look at <seealso cref="RandomizerForProperty{TTargetPoco,TTargetType}(System.Func{TTargetType},System.Linq.Expressions.Expression{System.Func{TTargetPoco,TTargetType}}[])"/>
17+
/// When you want to change the randomizer of a specific propery look at <seealso cref="RandomizerForProperty{TTargetType}(System.Func{TTargetType},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}}[])"/>
1418
/// </summary>
1519
/// <typeparam name="TTargetType">Type for which the randomizer will be set. For example string, int, etc...</typeparam>
1620
/// <param name="randomizer">The randomizer delegate has the task to generate the random data for the given <see cref="TTargetType"/></param>
@@ -19,7 +23,7 @@ public interface IFluentFillerApi<TTargetObject>
1923
/// <summary>
2024
/// Sets the randomizer for the given type with a implementation of the <see cref="IRandomizerPlugin{T}"/>.
2125
/// This will then be the default way to generate data for the given <see cref="TTargetType"/>.
22-
/// When you want to change the randomizer of a specific propery look at <seealso cref="RandomizerForProperty{TTargetPoco,TTargetType}(System.Func{TTargetType},System.Linq.Expressions.Expression{System.Func{TTargetPoco,TTargetType}}[])"/>
26+
/// When you want to change the randomizer of a specific propery look at <seealso cref="RandomizerForProperty{TTargetType}(System.Func{TTargetType},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}}[])"/>
2327
/// </summary>
2428
/// <typeparam name="TTargetType">Type for which the randomizer plugin will be set. For example string, int, etc...</typeparam>
2529
/// <param name="randomizerPlugin">The randomizer plugin has the task to generate random data for the given <see cref="TTargetType"/></param>

ObjectFiller/ObjectFiller.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66

77
namespace ObjectFiller
88
{
9+
/// <summary>
10+
/// The ObjectFiller.NET fills the public properties of your .NET object
11+
/// with random data
12+
/// </summary>
13+
/// <typeparam name="T">Targettype of the object to fill</typeparam>
914
public class ObjectFiller<T> where T : class
1015
{
16+
/// <summary>
17+
/// Default constructor
18+
/// </summary>
1119
public ObjectFiller()
1220
{
1321
SetupManager.Clear();
@@ -64,7 +72,7 @@ private object CreateInstanceOfType(Type type, ObjectFillerSetup currentSetup)
6472

6573
if (type.GetConstructors().All(ctor => ctor.GetParameters().Length != 0))
6674
{
67-
IEnumerable<ConstructorInfo> ctorInfos = null;
75+
IEnumerable<ConstructorInfo> ctorInfos;
6876
if ((ctorInfos = type.GetConstructors().Where(ctr => ctr.GetParameters().Length != 0)).Count() != 0)
6977
{
7078
foreach (ConstructorInfo ctorInfo in ctorInfos.OrderBy(x => x.GetParameters().Length))
@@ -150,17 +158,19 @@ private object GetFilledObject(Type type, ObjectFillerSetup currentSetup)
150158

151159
return dictionary;
152160
}
153-
else if (TypeIsList(type))
161+
162+
if (TypeIsList(type))
154163
{
155164
IList list = GetFilledList(type, currentSetup);
156165
return list;
157166
}
158167

159-
else if (type.IsInterface)
168+
if (type.IsInterface)
160169
{
161170
return GetInterfaceInstance(type, currentSetup);
162171
}
163-
else if (TypeIsPoco(type))
172+
173+
if (TypeIsPoco(type))
164174
{
165175
return GetFilledPoco(type, currentSetup);
166176
}
@@ -263,7 +273,7 @@ private object GetInterfaceInstance(Type interfaceType, ObjectFillerSetup setup)
263273
}
264274

265275
MethodInfo method = setup.InterfaceMocker.GetType().GetMethod("Create");
266-
MethodInfo genericMethod = method.MakeGenericMethod(new Type[] { interfaceType });
276+
MethodInfo genericMethod = method.MakeGenericMethod(new[] { interfaceType });
267277
result = genericMethod.Invoke(setup.InterfaceMocker, null);
268278
}
269279
FillInternal(result);

ObjectFiller/ObjectFillerApi.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66

77
namespace ObjectFiller
88
{
9+
/// <summary>
10+
/// Implementation of the <see cref="IFluentFillerApi{TTargetObject}"/>
11+
/// </summary>
12+
/// <typeparam name="TTargetObject">Type which will be configured for the ObjectFiller.NET</typeparam>
913
public class ObjectFillerApi<TTargetObject> : IFluentFillerApi<TTargetObject>
1014
where TTargetObject : class
1115
{
1216
/// <summary>
1317
/// Sets the randomizer for the given type with a function delegate.
1418
/// This will then be the default way to generate data for the given <see cref="TTargetType"/>.
15-
/// When you want to change the randomizer of a specific propery look at <seealso cref="IFluentFillerApi{TTargetObject}.RandomizerForProperty{TTargetObject,TTargetType}(System.Func{TTargetType},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}}[])"/>
19+
/// When you want to change the randomizer of a specific propery look at <seealso cref="IFluentFillerApi{TTargetObject}.RandomizerForProperty{TTargetType}(System.Func{TTargetType},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}}[])"/>
1620
/// </summary>
1721
/// <typeparam name="TTargetType">Type for which the randomizer will be set. For example string, int, etc...</typeparam>
1822
/// <param name="randomizer">The randomizer delegate has the task to generate the random data for the given <see cref="TTargetType"/></param>
@@ -25,7 +29,7 @@ public IFluentFillerApi<TTargetObject> RandomizerForType<TTargetType>(Func<TTarg
2529
/// <summary>
2630
/// Sets the randomizer for the given type with a implementation of the <see cref="IRandomizerPlugin{T}"/>.
2731
/// This will then be the default way to generate data for the given <see cref="TTargetType"/>.
28-
/// When you want to change the randomizer of a specific propery look at <seealso cref="IFluentFillerApi{TTargetObject}.RandomizerForProperty{TTargetObject,TTargetType}(System.Func{TTargetType},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}}[])"/>
32+
/// When you want to change the randomizer of a specific propery look at <seealso cref="IFluentFillerApi{TTargetObject}.RandomizerForProperty{TTargetType}(System.Func{TTargetType},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}},System.Linq.Expressions.Expression{System.Func{TTargetObject,TTargetType}}[])"/>
2933
/// </summary>
3034
/// <typeparam name="TTargetType">Type for which the randomizer plugin will be set. For example string, int, etc...</typeparam>
3135
/// <param name="randomizerPlugin">The randomizer plugin has the task to generate random data for the given <see cref="TTargetType"/></param>
@@ -50,7 +54,7 @@ public IFluentFillerApi<TTargetObject> RandomizerForType<TTargetType>(IRandomize
5054
public IFluentFillerApi<TTargetObject> RandomizerForProperty<TTargetType>(Func<TTargetType> randomizer, Expression<Func<TTargetObject, TTargetType>> property,
5155
params Expression<Func<TTargetObject, TTargetType>>[] additionalProperties)
5256
{
53-
var properties = new List<Expression<Func<TTargetObject, TTargetType>>>() { property };
57+
var properties = new List<Expression<Func<TTargetObject, TTargetType>>> { property };
5458

5559

5660
if (additionalProperties.Length > 0)
@@ -104,7 +108,7 @@ public IFluentFillerApi<TTargetObject> RandomizerForProperty<TTargetType>(IRando
104108
public IFluentFillerApi<TTargetObject> IgnoreProperties(Expression<Func<TTargetObject, object>> propertyToIgnore, params Expression<Func<TTargetObject, object>>[] additionalProperties)
105109
// where TTargetObject : class
106110
{
107-
var propertiesToIgnore = new List<Expression<Func<TTargetObject, object>>>() { propertyToIgnore };
111+
var propertiesToIgnore = new List<Expression<Func<TTargetObject, object>>> { propertyToIgnore };
108112
if (additionalProperties != null && additionalProperties.Length > 0)
109113
{
110114
propertiesToIgnore.AddRange(additionalProperties);

ObjectFiller/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
3333
// übernehmen, indem Sie "*" eingeben:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.2.0")]
36-
[assembly: AssemblyFileVersion("1.1.2.0")]
35+
[assembly: AssemblyVersion("1.1.4.0")]
36+
[assembly: AssemblyFileVersion("1.1.4.0")]

ObjectFiller/SetupManager.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,38 @@
33

44
namespace ObjectFiller
55
{
6+
/// <summary>
7+
/// Responsible to get the right <see cref="ObjectFillerSetup"/> for a given type.
8+
/// </summary>
69
public static class SetupManager
710
{
811
private static ObjectFillerSetup _mainSetup;
912
private static Dictionary<Type, ObjectFillerSetup> _typeToSetup;
1013

11-
14+
/// <summary>
15+
/// static ctor
16+
/// </summary>
1217
static SetupManager()
1318
{
1419
Clear();
1520
}
1621

17-
18-
22+
/// <summary>
23+
/// Gets the <see cref="ObjectFillerSetup"/> for a given type
24+
/// </summary>
25+
/// <typeparam name="TTargetObject">Type for which a <see cref="ObjectFillerSetup"/> will be get</typeparam>
26+
/// <returns><see cref="ObjectFillerSetup"/> for type <see cref="TTargetObject"/></returns>
1927
public static ObjectFillerSetup GetFor<TTargetObject>()
2028
where TTargetObject : class
2129
{
2230
return GetFor(typeof(TTargetObject));
2331
}
2432

33+
/// <summary>
34+
/// Gets the <see cref="ObjectFillerSetup"/> for a given type
35+
/// </summary>
36+
/// <param name="targetType">Type for which a <see cref="ObjectFillerSetup"/> will be get</param>
37+
/// <returns><see cref="ObjectFillerSetup"/> for type <see cref="targetType"/></returns>
2538
public static ObjectFillerSetup GetFor(Type targetType)
2639
{
2740
if (_typeToSetup.ContainsKey(targetType))
@@ -32,18 +45,29 @@ public static ObjectFillerSetup GetFor(Type targetType)
3245
return _mainSetup;
3346
}
3447

35-
48+
/// <summary>
49+
/// Sets a new <see cref="ObjectFillerSetup"/> for the given <see cref="TTargetObject"/>
50+
/// </summary>
51+
/// <typeparam name="TTargetObject">Type of target object for which a new <see cref="ObjectFillerSetup"/> will be set.</typeparam>
52+
/// <param name="useDefaultSettings">FALSE if the target object will take the settings of the parent object</param>
3653
public static void SetNewFor<TTargetObject>(bool useDefaultSettings)
3754
where TTargetObject : class
3855
{
3956
_typeToSetup[typeof(TTargetObject)] = useDefaultSettings ? new ObjectFillerSetup() : _mainSetup;
4057
}
4158

59+
/// <summary>
60+
/// Set the main <see cref="ObjectFillerSetup"/>. This will be the root setup.
61+
/// </summary>
62+
/// <param name="setup">Main setup</param>
4263
public static void SetMain(ObjectFillerSetup setup)
4364
{
4465
_mainSetup = setup;
4566
}
4667

68+
/// <summary>
69+
/// Clears all the settings which was made.
70+
/// </summary>
4771
public static void Clear()
4872
{
4973
_mainSetup = new ObjectFillerSetup();

Tynamix.ObjectFiller.1.1.1.nupkg

-46 KB
Binary file not shown.

Tynamix.ObjectFiller.1.1.4.nupkg

46.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)