* Run code cleanup * Dotnet format benchmarks project * Fix up Test.Common * Run dotnet format + manual cleanup * Run code cleanup for unit tests * Run dotnet format * Fix up errors * Manual cleanup of Unit test project * Update tests/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Testing/TestDbMeta.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Benchmarks/TypeFinderBenchmarks.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Umbraco.Core/Events/EventAggregatorTests.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Fix according to review * Fix after merge * Fix errors Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> Co-authored-by: Zeegaan <nge@umbraco.dk>
73 lines
1.5 KiB
C#
73 lines
1.5 KiB
C#
using NUnit.Framework;
|
|
using Umbraco.Cms.Core.Collections;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Collections;
|
|
|
|
[TestFixture]
|
|
public class StackQueueTests
|
|
{
|
|
[Test]
|
|
public void Queue()
|
|
{
|
|
var sq = new StackQueue<int>();
|
|
for (var i = 0; i < 3; i++)
|
|
{
|
|
sq.Enqueue(i);
|
|
}
|
|
|
|
var expected = 0;
|
|
while (sq.Count > 0)
|
|
{
|
|
var next = sq.Dequeue();
|
|
Assert.AreEqual(expected, next);
|
|
expected++;
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void Stack()
|
|
{
|
|
var sq = new StackQueue<int>();
|
|
for (var i = 0; i < 3; i++)
|
|
{
|
|
sq.Push(i);
|
|
}
|
|
|
|
var expected = 2;
|
|
while (sq.Count > 0)
|
|
{
|
|
var next = sq.Pop();
|
|
Assert.AreEqual(expected, next);
|
|
expected--;
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void Stack_And_Queue()
|
|
{
|
|
var sq = new StackQueue<int>();
|
|
for (var i = 0; i < 5; i++)
|
|
{
|
|
if (i % 2 == 0)
|
|
{
|
|
sq.Push(i);
|
|
}
|
|
else
|
|
{
|
|
sq.Enqueue(i);
|
|
}
|
|
}
|
|
|
|
// 4 (push)
|
|
// 3 (enqueue)
|
|
// 2 (push)
|
|
// 1 (enqueue)
|
|
// 0 (push)
|
|
Assert.AreEqual(4, sq.Pop());
|
|
Assert.AreEqual(0, sq.Dequeue());
|
|
Assert.AreEqual(3, sq.Pop());
|
|
Assert.AreEqual(1, sq.Dequeue());
|
|
Assert.AreEqual(2, sq.Pop());
|
|
}
|
|
}
|