public int RunArrayProvider()
        {
            var list = new List <int> {
                1, 2, 3
            };

            ArrayProvider <int> .GetWrappedArray(list);

            return(list.Count);
        }
Example #2
0
        public void ShouldFailWithNotSupportedExceptionForReadonlyCollectionThatIsNotCreatedFromArrayEitherList()
        {
            IList <int> customCollection = new MyCustomCollection <int>();

            var readOnlyCollection = new ReadOnlyCollection <int>(customCollection);

            Assert.That(
                () => ArrayProvider <int> .GetWrappedArray(readOnlyCollection),
                Throws.InstanceOf <NotSupportedException>());
        }
Example #3
0
        public void CreateFromArrayShouldNotAllocateAnyMemory()
        {
            var array = StrongEnumerable.Range(0, 10).Select(_ => _).ToArray();

            var list = ListFactory <int> .Create(array);

            var extractedArray = ArrayProvider <int> .GetWrappedArray(list);

            Assert.AreSame(array, extractedArray);
            CollectionAssert.AreEqual(array, list);
        }
Example #4
0
        private void EnsureThatArrayProviderReturnsWrappedArray(IList <int> numbers)
        {
            var readOnlyCollection = new ReadOnlyCollection <int>(numbers);

            var wrappedArray = ArrayProvider <int> .GetWrappedArray(readOnlyCollection);

            for (int i = 0; i < 5; i++)
            {
                Assert.That(numbers[i], Is.EqualTo(wrappedArray[i]));
            }
        }
Example #5
0
        public void ShouldReturnArrayThatListJustWraps()
        {
            var numbers = Enumerable.Range(1, 5).ToList();

            var wrappedArray = ArrayProvider <int> .GetWrappedArray(numbers);

            for (int i = 0; i < 5; i++)
            {
                Assert.That(numbers[i], Is.EqualTo(wrappedArray[i]));
            }
        }
Example #6
0
 public int[] GetArrayFromListDynamicCIL()
 {
     return(ArrayProvider <int> .GetWrappedArray(ListOfSmallValueTypes));
 }