using Recyclable.Collections; namespace Recyclable.CollectionsTests { public static class RecyclableListTestData { private static IEnumerable DoCreateTestData(long itemsCount) { for (long index = 1; index <= itemsCount; index++) { yield return index; } } public static IEnumerable CreateTestData(long itemsCount) => DoCreateTestData(itemsCount).ToArray(); public static readonly IEnumerable ItemsCountVariants = new long[] { 0, 1, 2, 3, 10, 16, 32, 64, 128, 256, 333, 512, 1_024, 8_192, 16_384, 1_000_000 }; public static readonly IEnumerable BlockSizeVariants = new int[] { 1, 2, 4, 8, 10, 16, 32, 64, 128, 256, 512, 1_024, 2_048, 4_096, 8_192, 16_384 }; private static IEnumerable GetTargetDataVariants() { foreach (var itemsCount in ItemsCountVariants) { foreach (var targetBlockSize in BlockSizeVariants) { yield return new object[] { itemsCount, targetBlockSize }; } } } public static IEnumerable TargetDataVariants => GetTargetDataVariants().ToArray(); private static IEnumerable CreateSourceDataVariants() { foreach (var itemsCount in ItemsCountVariants) { yield return new object[] { $"int[{itemsCount}]", CreateTestData(itemsCount).ToArray(), itemsCount }; yield return new object[] { $"List(itemsCount: {itemsCount}", CreateTestData(itemsCount).ToList(), itemsCount }; yield return new object[] { $"RecyclableArrayList(itemsCount: {itemsCount})", CreateTestData(itemsCount).ToRecyclableArrayList(), itemsCount }; foreach (var sourceBlockSize in BlockSizeVariants) { yield return new object[] { $"RecyclableList(itemsCount: {itemsCount}, minBlockSize: {sourceBlockSize})", CreateTestData(itemsCount).ToRecyclableList(sourceBlockSize), itemsCount }; } yield return new object[] { $"IList(itemsCount: {itemsCount})", new CustomIList(CreateTestData(itemsCount)), itemsCount }; yield return new object[] { $"IEnumerable(itemsCount: {itemsCount}) with non-enumerated count", CreateTestData(itemsCount), itemsCount }; yield return new object[] { $"IEnumerable(itemsCount: {itemsCount}) without non-enumerated count", new EnumerableWithoutCount(CreateTestData(itemsCount)), itemsCount }; } } public static IEnumerable SourceDataVariants => CreateSourceDataVariants().ToArray(); private static IEnumerable CreateSourceEmptyDataVariants() => new[] { new object[] { "int[]", Array.Empty() }, new object[] { "List", Array.Empty().ToList() }, new object[] { "RecyclableArrayList", Array.Empty().ToRecyclableArrayList() }, new object[] { "RecyclableList", Array.Empty().ToRecyclableList() }, new object[] { "IList", new CustomIList(Array.Empty()) }, new object[] { "IEnumerable with non-enumerated count", Array.Empty().AsEnumerable() }, new object[] { "IEnumerable without non-enumerated count", new EnumerableWithoutCount(Array.Empty()) } }; public static IEnumerable EmptySourceDataVariants => CreateSourceEmptyDataVariants().ToArray(); private static IEnumerable CreateSourceTargetDataVariants() { foreach (var testData in SourceDataVariants) { foreach (var targetBlockSize in BlockSizeVariants) { yield return new object[] { testData[0], testData[1], testData[2], targetBlockSize }; } } } public static IEnumerable SourceTargetDataVariants => CreateSourceTargetDataVariants().ToArray(); } }