示例#1
0
        public void create_array_happy_path()
        {
            var result = CollectionFactory.CreateArray(3, i => i);

            result.Length.ShouldBe(3);
            result[0].ShouldBe(0);
            result[1].ShouldBe(1);
            result[2].ShouldBe(2);
        }
示例#2
0
        public void get_page_throws_exception_when_asking_for_page_higher_than_page_count()
        {
            var collection = CollectionFactory.CreateArray(10, x => Rand.NextInt());

            Assert.Throws <lib12Exception>(() => collection.GetPage(3, 5));
        }
示例#3
0
        public void get_page_throws_exception_if_number_of_page_is_less_than_one()
        {
            var collection = CollectionFactory.CreateArray(10, x => Rand.NextInt());

            Assert.Throws <lib12Exception>(() => collection.GetPage(0, 5));
        }
示例#4
0
 public void create_array_throws_exception_when_create_function_is_null()
 {
     Assert.Throws <ArgumentNullException>(() => CollectionFactory.CreateArray(12, (Func <int, int>)null));
 }
示例#5
0
 public void create_array_throws_exception_when_size_is_negative()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => CollectionFactory.CreateArray(-1, i => i));
 }
示例#6
0
        public void create_array_works_with_size_equal_to_zero()
        {
            var result = CollectionFactory.CreateArray(0, i => i);

            result.ShouldBeEmpty();
        }
示例#7
0
 /// <summary>
 /// Returns an array of random objects of given type
 /// </summary>
 /// <typeparam name="T">The type to generate</typeparam>
 /// <param name="count">The count of objects to generate</param>
 /// <param name="constrains">The constrains for generating properties</param>
 /// <returns></returns>
 public static T[] NextArrayOf <T>(int count, ConstrainCollection constrains = null) where T : class
 {
     return(CollectionFactory
            .CreateArray(count, i => Next <T>(constrains)));
 }
示例#8
0
 /// <summary>
 /// Returns a random string with provided length
 /// </summary>
 /// <param name="length">Returned string length</param>
 /// <returns>Random string with provided length</returns>
 public static string NextString(int length)
 {
     return(new string(CollectionFactory.CreateArray(10, i => NextLowercaseLetter())));
 }