Missing IList<T> interface added. Tiny cleanup.

This commit is contained in:
mlemanczyk committed 2023-01-15 20:19:01 +01:00
1 parent 8067bfb542
commit 4bfb40007a
2 files changed
+18 -10

No files matched your search

+1 -10
View File
@@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
namespace Recyclable.Collections
{
public class RecyclableArrayList<T> : IEnumerable<T>, IDisposable
public class RecyclableArrayList<T> : IEnumerable<T>, IList<T>, IDisposable
{
private static readonly ArrayPool<T> _arrayPool = ArrayPool<T>.Create();
private static readonly IEqualityComparer<T> _equalityComparer = EqualityComparer<T>.Default;
@@ -296,15 +296,6 @@ namespace Recyclable.Collections
}
_count = targetIndex;
//foreach (var item in source)
//{
// if (capacity == count)
// {
// }
// Add(item);
//}
}
public void Clear()
@@ -237,5 +237,22 @@ namespace Recyclable.CollectionsTests
.And.ContainInConsecutiveOrder(testData)
.And.BeEquivalentTo(testData);
}
[Fact]
public void CopyToShouldCopyAllItemsInTheCorrectOrder()
{
// Prepare
var testData = _testData.ToArray();
var list = new RecyclableArrayList<int>(testData);
int[] yieldedItems = new int[testData.Length];
// Act
list.CopyTo(yieldedItems, 0);
// Validate
_ = yieldedItems.Should().HaveCount(testData.Length)
.And.ContainInConsecutiveOrder(testData)
.And.BeEquivalentTo(testData);
}
}
}