File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1
1
namespace ObjectFiller . Test
2
2
{
3
3
using System ;
4
+ using System . Collections . Generic ;
4
5
using System . Linq ;
5
6
6
7
using Microsoft . VisualStudio . TestTools . UnitTesting ;
@@ -45,7 +46,16 @@ public void TryingToCreateAnObjectWithAnInterfaceShallFailAndHaveAnInnerexceptio
45
46
Assert . IsNotNull ( ex . InnerException ) ;
46
47
throw ;
47
48
}
48
-
49
+ }
50
+
51
+ [ TestMethod ]
52
+ public void RandomizerCreatesAListOfRandomItemsIfNeeded ( )
53
+ {
54
+ int amount = 5 ;
55
+
56
+ IEnumerable < int > result = Randomizer < int > . Create ( amount ) ;
57
+
58
+ Assert . AreEqual ( amount , result . Count ( ) ) ;
49
59
}
50
60
51
61
}
Original file line number Diff line number Diff line change 10
10
namespace Tynamix . ObjectFiller
11
11
{
12
12
using System ;
13
+ using System . Collections . Generic ;
13
14
using System . Linq ;
15
+ using System . Runtime . CompilerServices ;
14
16
15
17
/// <summary>
16
18
/// This class is a easy way to get random values.
@@ -65,6 +67,22 @@ public static T Create()
65
67
return ( T ) Setup . TypeToRandomFunc [ typeof ( T ) ] ( ) ;
66
68
}
67
69
70
+ /// <summary>
71
+ /// Creates a set of random items of the given type. It will use a <see cref="IRandomizerPlugin{T}"/> for that.
72
+ /// </summary>
73
+ /// <param name="amount">Amount of items created.</param>
74
+ /// <returns>Set of random items of the given type.</returns>
75
+ public static IEnumerable < T > Create ( int amount )
76
+ {
77
+ var resultSet = new List < T > ( ) ;
78
+ for ( int i = 0 ; i < amount ; i ++ )
79
+ {
80
+ resultSet . Add ( Create ( ) ) ;
81
+ }
82
+
83
+ return resultSet ;
84
+ }
85
+
68
86
/// <summary>
69
87
/// Creates a random value of the target type. It will use a <see cref="IRandomizerPlugin{T}"/> for that
70
88
/// </summary>
You can’t perform that action at this time.
0 commit comments