RecyclableList.Remove modified to allow removing the last item.
This commit is contained in:
1 parent
ec355160f9
commit
2558f57934
2 files changed
+34
-2
No files matched your search
@@ -186,6 +186,27 @@ namespace Recyclable.CollectionsTests
|
||||
_ = Assert.Throws<NotSupportedException>(() => list.Insert(0, -1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveShouldRemoveLastItem()
|
||||
{
|
||||
// Prepare
|
||||
using var list = NewRecyclableList;
|
||||
|
||||
int removedCount = 0;
|
||||
var testData = _testData.ToArray();
|
||||
foreach (var item in _testData.Reverse())
|
||||
{
|
||||
// Act & Validate
|
||||
_ = list.Remove(item).Should().BeTrue($"we search for {item} which should exist");
|
||||
removedCount++;
|
||||
var expectedList = testData[0..(testData.Length - removedCount)];
|
||||
_ = list.LongCount.Should().Be(expectedList.Length);
|
||||
_ = list.Should().ContainInConsecutiveOrder(expectedList);
|
||||
}
|
||||
|
||||
_ = list.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveShouldRaiseNotSupportedException()
|
||||
{
|
||||
@@ -193,7 +214,7 @@ namespace Recyclable.CollectionsTests
|
||||
using var list = NewRecyclableList;
|
||||
|
||||
// Act
|
||||
_ = Assert.Throws<NotSupportedException>(() => list.Remove(_testData.First()));
|
||||
_ = Assert.Throws<ArgumentOutOfRangeException>(() => list.Remove(_testData.First()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in new issue
Block a user