Test RecyclableArrayList.ContainsShouldNotFindNonExistingItems and ContainsShouldNotFindAnythingWhenListEmpty added.
This commit is contained in:
1 parent
50353aecc2
commit
681cd179d2
1 file changed
+47
-16
@@ -303,35 +303,66 @@ namespace Recyclable.CollectionsTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void AddShouldAcceptDuplicates()
|
public void ContainsShouldNotFindNonExistingItems()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
int[] testNumbers = new[] { 1, 2, 2, 3 };
|
var testData = _testData.ToArray();
|
||||||
|
using var list = new RecyclableArrayList<int>(testData);
|
||||||
|
_ = testData.Any().Should().BeTrue("we need items on the list that we can look for");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
using var list = new RecyclableArrayList<int>();
|
foreach (var item in testData)
|
||||||
foreach (var index in testNumbers)
|
|
||||||
{
|
{
|
||||||
list.Add(index);
|
// Validate
|
||||||
|
_ = list.Contains(-item).Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
_ = list.Count.Should().Be(testNumbers.Length);
|
_ = list.Contains(0).Should().BeFalse();
|
||||||
_ = list.Should().BeEquivalentTo(testNumbers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ConstructorShouldAcceptDuplicates()
|
public void ContainsShouldNotFindAnythingWhenListEmpty()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
int[] testNumbers = new[] { 1, 2, 2, 3 };
|
var testData = _testData.ToArray();
|
||||||
|
using var list = new RecyclableArrayList<int>(testData);
|
||||||
// Act
|
|
||||||
using var list = new RecyclableArrayList<int>(testNumbers);
|
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
_ = list.Count.Should().Be(testNumbers.Length);
|
_ = list.Contains(0).Should().BeFalse();
|
||||||
_ = list.Should().BeEquivalentTo(testNumbers);
|
_ = list.Contains(1).Should().BeTrue();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
[Fact]
|
||||||
|
public void AddShouldAcceptDuplicates()
|
||||||
|
{
|
||||||
|
// Prepare
|
||||||
|
int[] testNumbers = new[] { 1, 2, 2, 3 };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
using var list = new RecyclableArrayList<int>();
|
||||||
|
foreach (var index in testNumbers)
|
||||||
|
{
|
||||||
|
list.Add(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate
|
||||||
|
_ = list.Count.Should().Be(testNumbers.Length);
|
||||||
|
_ = list.Should().BeEquivalentTo(testNumbers);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ConstructorShouldAcceptDuplicates()
|
||||||
|
{
|
||||||
|
// Prepare
|
||||||
|
int[] testNumbers = new[] { 1, 2, 2, 3 };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
using var list = new RecyclableArrayList<int>(testNumbers);
|
||||||
|
|
||||||
|
// Validate
|
||||||
|
_ = list.Count.Should().Be(testNumbers.Length);
|
||||||
|
_ = list.Should().BeEquivalentTo(testNumbers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user