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.
64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
using NUnit.Framework;
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
namespace Robust.UnitTesting.Client.UserInterface.Controls
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(RadioOptions<int>))]
|
|
public sealed class RadioOptionsTest : RobustUnitTest
|
|
{
|
|
public override UnitTestProject Project => UnitTestProject.Client;
|
|
|
|
[Test]
|
|
public void TestDefaultInvoke()
|
|
{
|
|
//Arrange
|
|
RadioOptions<int> _optionButton = new RadioOptions<int>(RadioOptionsLayout.Horizontal);
|
|
|
|
int itemId = _optionButton.AddItem("High", 1);
|
|
|
|
int countSelected = 0;
|
|
_optionButton.OnItemSelected += args =>
|
|
{
|
|
countSelected++;
|
|
};
|
|
|
|
//Act
|
|
_optionButton.InvokeItemSelected(new RadioOptionItemSelectedEventArgs<int>(itemId, _optionButton));
|
|
|
|
//Assert
|
|
Assert.That(countSelected, Is.EqualTo(1));
|
|
}
|
|
|
|
[Test]
|
|
public void TestOverrideInvoke()
|
|
{
|
|
//Arrange
|
|
RadioOptions<int> _optionButton = new RadioOptions<int>(RadioOptionsLayout.Horizontal);
|
|
|
|
int countSelected = 0;
|
|
|
|
int itemId = _optionButton.AddItem("High", 1, args => { countSelected--; });
|
|
int itemId2 = _optionButton.AddItem("High", 2);
|
|
|
|
_optionButton.OnItemSelected += args =>
|
|
{
|
|
countSelected++;
|
|
};
|
|
|
|
//Act
|
|
_optionButton.InvokeItemSelected(new RadioOptionItemSelectedEventArgs<int>(itemId, _optionButton));
|
|
|
|
//Assert
|
|
Assert.That(countSelected, Is.EqualTo(-1));
|
|
|
|
//Act
|
|
_optionButton.InvokeItemSelected(new RadioOptionItemSelectedEventArgs<int>(itemId2, _optionButton));
|
|
_optionButton.InvokeItemSelected(new RadioOptionItemSelectedEventArgs<int>(itemId2, _optionButton));
|
|
|
|
//Assert
|
|
Assert.That(countSelected, Is.EqualTo(1));
|
|
}
|
|
}
|
|
}
|