Files
RobustToolbox/Robust.Shared.Tests/Utility/CollectionExtensions_Test.cs
PJB3005 788e9386fd Split up test project
Robust.UnitTesting was both ALL tests for RT, and also API surface for content tests.

Tests are now split into separate projects as appropriate, and the API side has also been split off.
2025-12-16 01:36:53 +01:00

35 lines
1.1 KiB
C#

using NUnit.Framework;
using Robust.Shared.Utility;
namespace Robust.Shared.Tests.Utility
{
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
[TestFixture]
internal sealed class CollectionExtensions_Test
{
[Test]
public void RemoveSwapTest()
{
var list = new List<int> {1, 2, 3};
list.RemoveSwap(2);
Assert.That(list, Is.EqualTo(new List<int> {1, 2}));
list = new List<int> {1, 2, 3};
list.RemoveSwap(0);
Assert.That(list, Is.EqualTo(new List<int> {3, 2}));
}
[Test]
public void TestFirstOrNull()
{
Assert.That(Enumerable.Empty<int>().FirstOrNull(), Is.Null);
Assert.That(new[] {1}.FirstOrNull(), Is.EqualTo(1));
Assert.That(new[] {1, 2, 3}.FirstOrNull(), Is.EqualTo(1));
Assert.That(Enumerable.Empty<int>().FirstOrNull(p => p == 2), Is.Null);
Assert.That(new[] {1}.FirstOrNull(p => p == 2), Is.Null);
Assert.That(new[] {1, 2, 3}.FirstOrNull(p => p == 2), Is.EqualTo(2));
}
}
}