Merge pull request #9288 from RoosterDragon/action-queue-order

Fix ActionQueue ordering
This commit is contained in:
Matthias Mailänder
2015-09-26 13:42:56 +02:00
4 changed files with 90 additions and 22 deletions

View File

@@ -0,0 +1,42 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using OpenRA.Primitives;
namespace OpenRA.Test.OpenRA.Game
{
[TestFixture]
class ActionQueueTest
{
[TestCase(TestName = "ActionQueue performs actions in order of time, then insertion order.")]
public void ActionsArePerformedOrderedByTimeThenByInsertionOrder()
{
var list = new List<int>();
var queue = new ActionQueue();
queue.Add(() => list.Add(1), 0);
queue.Add(() => list.Add(7), 2);
queue.Add(() => list.Add(8), 2);
queue.Add(() => list.Add(4), 1);
queue.Add(() => list.Add(2), 0);
queue.Add(() => list.Add(3), 0);
queue.Add(() => list.Add(9), 2);
queue.Add(() => list.Add(5), 1);
queue.Add(() => list.Add(6), 1);
queue.PerformActions(1);
queue.PerformActions(2);
queue.PerformActions(3);
if (!list.SequenceEqual(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }))
Assert.Fail("Actions were not performed in the correct order. Actual order was: " + string.Join(", ", list));
}
}
}

View File

@@ -45,6 +45,7 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="OpenRA.Game\ActionQueueTest.cs" />
<Compile Include="OpenRA.Game\MiniYamlTest.cs" />
<Compile Include="OpenRA.Game\ActorInfoTest.cs" />
<Compile Include="OpenRA.Game\CoordinateTest.cs" />