Upgrade unit testing
This commit is contained in:
@@ -58,24 +58,24 @@ namespace OpenRA.Test
|
||||
|
||||
var queue = new Primitives.PriorityQueue<int, Int32Comparer>(default);
|
||||
|
||||
Assert.IsTrue(queue.Empty, "New queue should start out empty.");
|
||||
Assert.That(queue.Empty, Is.True, "New queue should start out empty.");
|
||||
Assert.Throws<InvalidOperationException>(() => queue.Peek(), "Peeking at an empty queue should throw.");
|
||||
Assert.Throws<InvalidOperationException>(() => queue.Pop(), "Popping an empty queue should throw.");
|
||||
|
||||
foreach (var value in shuffledValues)
|
||||
{
|
||||
queue.Add(value);
|
||||
Assert.IsFalse(queue.Empty, "Queue should not be empty - items have been added.");
|
||||
Assert.That(queue.Empty, Is.False, "Queue should not be empty - items have been added.");
|
||||
}
|
||||
|
||||
foreach (var value in values)
|
||||
{
|
||||
Assert.AreEqual(value, queue.Peek(), "Peek returned the wrong item - should be in order.");
|
||||
Assert.IsFalse(queue.Empty, "Queue should not be empty yet.");
|
||||
Assert.AreEqual(value, queue.Pop(), "Pop returned the wrong item - should be in order.");
|
||||
Assert.That(value, Is.EqualTo(queue.Peek()), "Peek returned the wrong item - should be in order.");
|
||||
Assert.That(queue.Empty, Is.False, "Queue should not be empty yet.");
|
||||
Assert.That(value, Is.EqualTo(queue.Pop()), "Pop returned the wrong item - should be in order.");
|
||||
}
|
||||
|
||||
Assert.IsTrue(queue.Empty, "Queue should now be empty.");
|
||||
Assert.That(queue.Empty, Is.True, "Queue should now be empty.");
|
||||
Assert.Throws<InvalidOperationException>(() => queue.Peek(), "Peeking at an empty queue should throw.");
|
||||
Assert.Throws<InvalidOperationException>(() => queue.Pop(), "Popping an empty queue should throw.");
|
||||
}
|
||||
@@ -102,53 +102,53 @@ namespace OpenRA.Test
|
||||
|
||||
var queue = new Primitives.PriorityQueue<int, Int32Comparer>(default);
|
||||
|
||||
Assert.IsTrue(queue.Empty, "New queue should start out empty.");
|
||||
Assert.That(queue.Empty, Is.True, "New queue should start out empty.");
|
||||
Assert.Throws<InvalidOperationException>(() => queue.Peek(), "Peeking at an empty queue should throw.");
|
||||
Assert.Throws<InvalidOperationException>(() => queue.Pop(), "Popping an empty queue should throw.");
|
||||
|
||||
foreach (var value in shuffledValues.Take(10))
|
||||
{
|
||||
queue.Add(value);
|
||||
Assert.IsFalse(queue.Empty, "Queue should not be empty - items have been added.");
|
||||
Assert.That(queue.Empty, Is.False, "Queue should not be empty - items have been added.");
|
||||
}
|
||||
|
||||
foreach (var value in shuffledValues.Take(10).OrderBy(x => x).Take(5))
|
||||
{
|
||||
Assert.AreEqual(value, queue.Peek(), "Peek returned the wrong item - should be in order.");
|
||||
Assert.IsFalse(queue.Empty, "Queue should not be empty yet.");
|
||||
Assert.AreEqual(value, queue.Pop(), "Pop returned the wrong item - should be in order.");
|
||||
Assert.That(value, Is.EqualTo(queue.Peek()), "Peek returned the wrong item - should be in order.");
|
||||
Assert.That(queue.Empty, Is.False, "Queue should not be empty yet.");
|
||||
Assert.That(value, Is.EqualTo(queue.Pop()), "Pop returned the wrong item - should be in order.");
|
||||
}
|
||||
|
||||
foreach (var value in shuffledValues.Skip(10).Take(5))
|
||||
{
|
||||
queue.Add(value);
|
||||
Assert.IsFalse(queue.Empty, "Queue should not be empty - items have been added.");
|
||||
Assert.That(queue.Empty, Is.False, "Queue should not be empty - items have been added.");
|
||||
}
|
||||
|
||||
foreach (var value in shuffledValues.Take(10).OrderBy(x => x).Skip(5)
|
||||
.Concat(shuffledValues.Skip(10).Take(5)).OrderBy(x => x).Take(5))
|
||||
{
|
||||
Assert.AreEqual(value, queue.Peek(), "Peek returned the wrong item - should be in order.");
|
||||
Assert.IsFalse(queue.Empty, "Queue should not be empty yet.");
|
||||
Assert.AreEqual(value, queue.Pop(), "Pop returned the wrong item - should be in order.");
|
||||
Assert.That(value, Is.EqualTo(queue.Peek()), "Peek returned the wrong item - should be in order.");
|
||||
Assert.That(queue.Empty, Is.False, "Queue should not be empty yet.");
|
||||
Assert.That(value, Is.EqualTo(queue.Pop()), "Pop returned the wrong item - should be in order.");
|
||||
}
|
||||
|
||||
foreach (var value in shuffledValues.Skip(15))
|
||||
{
|
||||
queue.Add(value);
|
||||
Assert.IsFalse(queue.Empty, "Queue should not be empty - items have been added.");
|
||||
Assert.That(queue.Empty, Is.False, "Queue should not be empty - items have been added.");
|
||||
}
|
||||
|
||||
foreach (var value in shuffledValues.Take(10).OrderBy(x => x).Skip(5)
|
||||
.Concat(shuffledValues.Skip(10).Take(5)).OrderBy(x => x).Skip(5)
|
||||
.Concat(shuffledValues.Skip(15)).OrderBy(x => x))
|
||||
{
|
||||
Assert.AreEqual(value, queue.Peek(), "Peek returned the wrong item - should be in order.");
|
||||
Assert.IsFalse(queue.Empty, "Queue should not be empty yet.");
|
||||
Assert.AreEqual(value, queue.Pop(), "Pop returned the wrong item - should be in order.");
|
||||
Assert.That(value, Is.EqualTo(queue.Peek()), "Peek returned the wrong item - should be in order.");
|
||||
Assert.That(queue.Empty, Is.False, "Queue should not be empty yet.");
|
||||
Assert.That(value, Is.EqualTo(queue.Pop()), "Pop returned the wrong item - should be in order.");
|
||||
}
|
||||
|
||||
Assert.IsTrue(queue.Empty, "Queue should now be empty.");
|
||||
Assert.That(queue.Empty, Is.True, "Queue should now be empty.");
|
||||
Assert.Throws<InvalidOperationException>(() => queue.Peek(), "Peeking at an empty queue should throw.");
|
||||
Assert.Throws<InvalidOperationException>(() => queue.Pop(), "Popping an empty queue should throw.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user