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 11namespace ObjectFiller . Test
22{
33 using System ;
4+ using System . Collections . Generic ;
45 using System . Linq ;
56
67 using Microsoft . VisualStudio . TestTools . UnitTesting ;
@@ -45,7 +46,16 @@ public void TryingToCreateAnObjectWithAnInterfaceShallFailAndHaveAnInnerexceptio
4546 Assert . IsNotNull ( ex . InnerException ) ;
4647 throw ;
4748 }
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 ( ) ) ;
4959 }
5060
5161 }
Original file line number Diff line number Diff line change 1010namespace Tynamix . ObjectFiller
1111{
1212 using System ;
13+ using System . Collections . Generic ;
1314 using System . Linq ;
15+ using System . Runtime . CompilerServices ;
1416
1517 /// <summary>
1618 /// This class is a easy way to get random values.
@@ -65,6 +67,22 @@ public static T Create()
6567 return ( T ) Setup . TypeToRandomFunc [ typeof ( T ) ] ( ) ;
6668 }
6769
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+
6886 /// <summary>
6987 /// Creates a random value of the target type. It will use a <see cref="IRandomizerPlugin{T}"/> for that
7088 /// </summary>
You can’t perform that action at this time.
0 commit comments