mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
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.
45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
using NUnit.Framework;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.IoC;
|
|
|
|
namespace Robust.UnitTesting.Client.UserInterface.Controls
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(MultiselectOptionButton<>))]
|
|
public sealed class MultiselectOptionButtonTest : RobustUnitTest
|
|
{
|
|
public override UnitTestProject Project => UnitTestProject.Client;
|
|
|
|
[Test]
|
|
public void TestAddRemoveItem()
|
|
{
|
|
var uiManager = IoCManager.Resolve<IUserInterfaceManagerInternal>();
|
|
uiManager.InitializeTesting();
|
|
var optionButton = new MultiselectOptionButton<string>();
|
|
optionButton.AddItem("Label1", "Key1");
|
|
optionButton.AddItem("Label2", "Key2");
|
|
optionButton.AddItem("Label3", "Key3");
|
|
|
|
Assert.That(optionButton.GetIdx("Key1"), Is.EqualTo(0));
|
|
Assert.That(optionButton.GetIdx("Key2"), Is.EqualTo(1));
|
|
Assert.That(optionButton.GetIdx("Key3"), Is.EqualTo(2));
|
|
Assert.That(optionButton.GetItemKey(0), Is.EqualTo("Key1"));
|
|
Assert.That(optionButton.GetItemKey(1), Is.EqualTo("Key2"));
|
|
Assert.That(optionButton.GetItemKey(2), Is.EqualTo("Key3"));
|
|
|
|
optionButton.RemoveItem(1);
|
|
|
|
Assert.That(optionButton.GetIdx("Key1"), Is.EqualTo(0));
|
|
Assert.That(optionButton.GetIdx("Key3"), Is.EqualTo(1));
|
|
Assert.That(optionButton.GetItemKey(0), Is.EqualTo("Key1"));
|
|
Assert.That(optionButton.GetItemKey(1), Is.EqualTo("Key3"));
|
|
|
|
optionButton.RemoveItem(0);
|
|
|
|
Assert.That(optionButton.GetIdx("Key3"), Is.EqualTo(0));
|
|
Assert.That(optionButton.GetItemKey(0), Is.EqualTo("Key3"));
|
|
}
|
|
}
|
|
}
|