Tests updated to match RecyclableSortedListTests.
This commit is contained in:
1 parent
984d951359
commit
bf07e05488
1 file changed
+39
-39
@@ -15,20 +15,20 @@ namespace Recyclable.CollectionsTests
|
|||||||
public void AddShouldAddItems()
|
public void AddShouldAddItems()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = new RecyclableList<int>();
|
using var list = new RecyclableList<int>();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const int itemsCount = 5;
|
const int itemsCount = 5;
|
||||||
foreach (var index in Enumerable.Range(1, itemsCount))
|
foreach (var index in Enumerable.Range(1, itemsCount))
|
||||||
{
|
{
|
||||||
sut.Add(index);
|
list.Add(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
_ = sut.Count.Should().Be(itemsCount, "we added so many items");
|
_ = list.Count.Should().Be(itemsCount, "we added so many items");
|
||||||
for (var index = 0; index < itemsCount; index++)
|
for (var index = 0; index < itemsCount; index++)
|
||||||
{
|
{
|
||||||
var actual = sut[index];
|
var actual = list[index];
|
||||||
_ = actual.Should().Be(index + 1);
|
_ = actual.Should().Be(index + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,15 +40,15 @@ namespace Recyclable.CollectionsTests
|
|||||||
int[] testNumbers = new[] { 1, 2, 2, 3 };
|
int[] testNumbers = new[] { 1, 2, 2, 3 };
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
using var sut = new RecyclableList<int>();
|
using var list = new RecyclableList<int>();
|
||||||
foreach (var index in testNumbers)
|
foreach (var index in testNumbers)
|
||||||
{
|
{
|
||||||
sut.Add(index);
|
list.Add(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
_ = sut.LongCount.Should().Be(testNumbers.Length);
|
_ = list.LongCount.Should().Be(testNumbers.Length);
|
||||||
_ = sut.Should().BeEquivalentTo(testNumbers);
|
_ = list.Should().BeEquivalentTo(testNumbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -58,11 +58,11 @@ namespace Recyclable.CollectionsTests
|
|||||||
int[] testNumbers = new[] { 1, 2, 2, 3 };
|
int[] testNumbers = new[] { 1, 2, 2, 3 };
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
using var sut = new RecyclableList<int>(testNumbers);
|
using var list = new RecyclableList<int>(testNumbers);
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
_ = sut.LongCount.Should().Be(testNumbers.Length);
|
_ = list.LongCount.Should().Be(testNumbers.Length);
|
||||||
_ = sut.Should().BeEquivalentTo(testNumbers);
|
_ = list.Should().BeEquivalentTo(testNumbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -71,32 +71,32 @@ namespace Recyclable.CollectionsTests
|
|||||||
var expectedList = _testData;
|
var expectedList = _testData;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
using RecyclableList<int> actualList = NewRecyclableList;
|
using RecyclableList<int> list = NewRecyclableList;
|
||||||
actualList.QuickSort();
|
list.QuickSort();
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
_ = actualList.LongCount.Should().Be(_totalObjectCount);
|
_ = list.LongCount.Should().Be(_totalObjectCount);
|
||||||
_ = actualList.Count.Should().Be(_totalObjectCount);
|
_ = list.Count.Should().Be(_totalObjectCount);
|
||||||
_ = actualList.Should().Equal(expectedList);
|
_ = list.Should().Equal(expectedList);
|
||||||
_ = expectedList.Should().AllSatisfy(expected => actualList.Contains(expected));
|
_ = expectedList.Should().AllSatisfy(expected => list.Contains(expected));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
actualList.Clear();
|
list.Clear();
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
_ = actualList.LongCount.Should().Be(0);
|
_ = list.LongCount.Should().Be(0);
|
||||||
_ = actualList.Count.Should().Be(0);
|
_ = list.Count.Should().Be(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CopyToShouldCopyAllItems()
|
public void CopyToShouldCopyAllItems()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = NewRecyclableList;
|
using var list = NewRecyclableList;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var actual = new int[sut.Count];
|
var actual = new int[list.Count];
|
||||||
sut.CopyTo(actual, 0);
|
list.CopyTo(actual, 0);
|
||||||
_ = actual.Should().BeEquivalentTo(_testData);
|
_ = actual.Should().BeEquivalentTo(_testData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,11 +104,11 @@ namespace Recyclable.CollectionsTests
|
|||||||
public void GetEnumeratorShouldYieldAllItems()
|
public void GetEnumeratorShouldYieldAllItems()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = NewRecyclableList;
|
using var list = NewRecyclableList;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var actual = new List<int>();
|
var actual = new List<int>();
|
||||||
var enumerator = sut.GetEnumerator();
|
var enumerator = list.GetEnumerator();
|
||||||
while (enumerator.MoveNext())
|
while (enumerator.MoveNext())
|
||||||
{
|
{
|
||||||
actual.Add(enumerator.Current);
|
actual.Add(enumerator.Current);
|
||||||
@@ -122,12 +122,12 @@ namespace Recyclable.CollectionsTests
|
|||||||
public void IndexOfShouldFindTheIndexes()
|
public void IndexOfShouldFindTheIndexes()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = NewRecyclableList;
|
using var list = NewRecyclableList;
|
||||||
|
|
||||||
// Act & Validate
|
// Act & Validate
|
||||||
foreach(var index in _testData)
|
foreach(var index in _testData)
|
||||||
{
|
{
|
||||||
var actual = sut.IndexOf(index);
|
var actual = list.IndexOf(index);
|
||||||
_ = actual.Should().Be(index - 1);
|
_ = actual.Should().Be(index - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,10 +137,10 @@ namespace Recyclable.CollectionsTests
|
|||||||
public void InsertShouldRaiseNotSupportedException()
|
public void InsertShouldRaiseNotSupportedException()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = NewRecyclableList;
|
using var list = NewRecyclableList;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
sut.Insert(0, -1);
|
list.Insert(0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@@ -148,10 +148,10 @@ namespace Recyclable.CollectionsTests
|
|||||||
public void RemoveShouldRaiseNotSupportedException()
|
public void RemoveShouldRaiseNotSupportedException()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = NewRecyclableList;
|
using var list = NewRecyclableList;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
bool removed = sut.Remove(_testData.First());
|
bool removed = list.Remove(_testData.First());
|
||||||
_ = removed.Should().BeFalse();
|
_ = removed.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,34 +160,34 @@ namespace Recyclable.CollectionsTests
|
|||||||
public void RemoveAtShouldRaiseNotSupportedException()
|
public void RemoveAtShouldRaiseNotSupportedException()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = NewRecyclableList;
|
using var list = NewRecyclableList;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
sut.RemoveAt(0);
|
list.RemoveAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void DisposeShouldSucceed()
|
public void DisposeShouldSucceed()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = NewRecyclableList;
|
using var list = NewRecyclableList;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
sut.Dispose();
|
list.Dispose();
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
_ = sut.LongCount.Should().Be(0L);
|
_ = list.LongCount.Should().Be(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void ConsecutiveDisposeShouldSucceed()
|
public void ConsecutiveDisposeShouldSucceed()
|
||||||
{
|
{
|
||||||
// Prepare
|
// Prepare
|
||||||
using var sut = NewRecyclableList;
|
using var list = NewRecyclableList;
|
||||||
sut.Dispose();
|
list.Dispose();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
sut.Dispose();
|
list.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user