Upgrade unit testing

This commit is contained in:
Gustas
2025-01-09 16:49:56 +02:00
committed by Paul Chote
parent bcbf88719f
commit 017e645557
10 changed files with 124 additions and 124 deletions

View File

@@ -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.");
}