Пример #1
0
        public int RunArrayProvider()
        {
            var list = new List <int> {
                1, 2, 3
            };

            ArrayProvider <int> .GetWrappedArray(list);

            return(list.Count);
        }
Пример #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>());
        }
Пример #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);
        }
Пример #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]));
            }
        }
Пример #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]));
            }
        }
Пример #6
0
 public int[] GetArrayFromListDynamicCIL()
 {
     return(ArrayProvider <int> .GetWrappedArray(ListOfSmallValueTypes));
 }