From 23e92b0521974f4cd202fdffaca83746efe3b422 Mon Sep 17 00:00:00 2001 From: Memek Date: Mon, 6 Feb 2023 18:02:50 +0100 Subject: [PATCH] Tests for RecyclableArrayList.Contains and RecyclableList.Clear added. --- .../RecyclableArrayListTests.cs | 19 ++++++++++++++++++- .../RecyclableListTests.cs | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Recyclable.CollectionsTests/RecyclableArrayListTests.cs b/Recyclable.CollectionsTests/RecyclableArrayListTests.cs index 1ba81a2..4f43224 100644 --- a/Recyclable.CollectionsTests/RecyclableArrayListTests.cs +++ b/Recyclable.CollectionsTests/RecyclableArrayListTests.cs @@ -17,7 +17,8 @@ namespace Recyclable.CollectionsTests // Act foreach (var item in testData) { - list.Add(item); + + _ = list.Count.Should().Be(item); } @@ -285,5 +286,21 @@ namespace Recyclable.CollectionsTests _ = actual.Should().Be(index - 1); } } + + [Fact] + public void ContainsShouldFindAllItems() + { + // Prepare + var testData = _testData.ToArray(); + using var list = new RecyclableArrayList(testData); + _ = testData.Any().Should().BeTrue("we need items on the list that we can look for"); + + // Act + foreach (var item in testData) + { + // Validate + _ = list.Contains(item).Should().BeTrue(); + } + } } } \ No newline at end of file diff --git a/Recyclable.CollectionsTests/RecyclableListTests.cs b/Recyclable.CollectionsTests/RecyclableListTests.cs index e89378a..1159dc8 100644 --- a/Recyclable.CollectionsTests/RecyclableListTests.cs +++ b/Recyclable.CollectionsTests/RecyclableListTests.cs @@ -137,7 +137,7 @@ namespace Recyclable.CollectionsTests { // Prepare using var list = NewRecyclableList; - + // Act var actual = new int[list.LongCount]; list.CopyTo(actual, 0); @@ -229,5 +229,19 @@ namespace Recyclable.CollectionsTests // Act list.Dispose(); } + + [Fact] + public void ClearShouldRemoveAllItems() + { + // Prepare + using var list = NewRecyclableList; + _ = list.LongCount.Should().NotBe(0); + + // Act + list.Clear(); + + // Validate + _ = list.LongCount.Should().Be(0); + } } } \ No newline at end of file