Files
Umbraco-CMS/tests/Umbraco.Tests.UnitTests/Umbraco.Core/Collections/StackQueueTests.cs
Shannon Deminick c77dc5dc00 Migrating tests that depend on Published Cache from the old test project (#11242)
* starts cleaning up old test project, removing ones we'll never convert, moves new test to where it should be.

* Makes ContentNodeKit immutable properties, moves first nucache tests over

* Gets the Nucache unit tests working and refactors a bit to use builder pattern for models.

* Migrates first xml based cache test to use nucache.

* Migrates a bunch more

* Migrates remaining tests for PublishedContentTests

* Moves PublishedRouterTests

* Moves PublishedContentExtensionTests

* Moves more tests.

* committing wip

* committing wip

* Gets PublishedContentLanguageVariantTests converted and working.

* Fixes DataTable ext method and moves PublishedContentDataTableTests

* Moves PublishedMediaTests

* wip - moving EntityXmlSerializerTests

* Moves more tests

* moves more tests

* moves more tests

* Move another test

* Moves more tests

* Fix test

* move another test

* Moves more tests

* Moves more tests

* Moves more tests

* wip before merge

* More tests

* More tests

* More tests

* More tests

* More tests

* More tests

* Cleanup and moving classes.

* Remove unused code

* Fixed failing tests, due to new null checks, that did not exist in v8

* Avoid breaking changes

* Unbreak more things, even that it the old solution was crazy..

* Fixed bug where ordering of stream readings was changed..

* cleanup

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2021-10-19 14:11:54 +02:00

75 lines
1.7 KiB
C#

using NUnit.Framework;
using Umbraco.Core.Collections;
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Collections
{
[TestFixture]
public class StackQueueTests
{
[Test]
public void Queue()
{
var sq = new StackQueue<int>();
for (int 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 (int 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 (int 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());
}
}
}