New tests added for IndexOf & LongIndexOf
This commit is contained in:
1 parent
0cd68fbb7c
commit
02138dfac6
1 file changed
+62
-1
@@ -163,7 +163,7 @@ namespace Recyclable.CollectionsTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IndexOfShouldFindTheIndexes()
|
||||
public void IndexOfShouldReturnCorrectIndexes()
|
||||
{
|
||||
// Prepare
|
||||
using var list = NewRecyclableList;
|
||||
@@ -176,6 +176,36 @@ namespace Recyclable.CollectionsTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IndexOfShouldNotFindNonExistingItems()
|
||||
{
|
||||
// Prepare
|
||||
var testData = _testData;
|
||||
using var list = NewRecyclableList;
|
||||
_ = testData.Any().Should().BeTrue("we need items on the list that we can look for");
|
||||
|
||||
// Act
|
||||
foreach (var item in testData)
|
||||
{
|
||||
// Validate
|
||||
_ = list.IndexOf(-item).Should().Be(-1);
|
||||
}
|
||||
|
||||
// Validate
|
||||
_ = list.IndexOf(0).Should().Be(-1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IndexOfShouldNotFindAnythingWhenListEmpty()
|
||||
{
|
||||
// Prepare
|
||||
using var list = new RecyclableList<int>();
|
||||
|
||||
// Validate
|
||||
_ = list.IndexOf(0).Should().Be(-1);
|
||||
_ = list.IndexOf(1).Should().Be(-1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InsertShouldRaiseNotSupportedException()
|
||||
{
|
||||
@@ -329,6 +359,37 @@ namespace Recyclable.CollectionsTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LongIndexOfShouldNotFindNonExistingItems()
|
||||
{
|
||||
// Prepare
|
||||
var testData = _testData;
|
||||
using var list = NewRecyclableList;
|
||||
_ = testData.Any().Should().BeTrue("we need items on the list that we can look for");
|
||||
|
||||
// Act
|
||||
foreach (var item in testData)
|
||||
{
|
||||
// Validate
|
||||
_ = list.LongIndexOf(-item).Should().Be(-1);
|
||||
}
|
||||
|
||||
// Validate
|
||||
_ = list.LongIndexOf(0).Should().Be(-1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LongIndexOfShouldNotFindAnythingWhenListEmpty()
|
||||
{
|
||||
// Prepare
|
||||
using var list = new RecyclableList<int>();
|
||||
|
||||
// Validate
|
||||
_ = list.LongIndexOf(0).Should().Be(-1);
|
||||
_ = list.LongIndexOf(1).Should().Be(-1);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ConstructorSourceShouldInitializeList()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user