public int RunArrayProvider() { var list = new List <int> { 1, 2, 3 }; ArrayProvider <int> .GetWrappedArray(list); return(list.Count); }
public void ShouldFailWithNotSupportedExceptionForReadonlyCollectionThatIsNotCreatedFromArrayEitherList() { IList <int> customCollection = new MyCustomCollection <int>(); var readOnlyCollection = new ReadOnlyCollection <int>(customCollection); Assert.That( () => ArrayProvider <int> .GetWrappedArray(readOnlyCollection), Throws.InstanceOf <NotSupportedException>()); }
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); }
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])); } }
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])); } }
public int[] GetArrayFromListDynamicCIL() { return(ArrayProvider <int> .GetWrappedArray(ListOfSmallValueTypes)); }