2021-02-11 01:13:03 -08:00
|
|
|
using System.IO;
|
2023-03-06 05:06:50 +00:00
|
|
|
using Content.Client.Alerts;
|
2020-11-09 20:22:19 -08:00
|
|
|
using Content.Shared.Alert;
|
|
|
|
|
using NUnit.Framework;
|
2022-01-05 00:19:23 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-11-09 20:22:19 -08:00
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
2022-01-05 00:19:23 -08:00
|
|
|
using Robust.Shared.Reflection;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager;
|
2020-11-09 20:22:19 -08:00
|
|
|
using Robust.Shared.Utility;
|
2023-03-06 05:06:50 +00:00
|
|
|
using Robust.UnitTesting;
|
2020-11-09 20:22:19 -08:00
|
|
|
|
|
|
|
|
namespace Content.Tests.Shared.Alert
|
|
|
|
|
{
|
2022-01-05 00:19:23 -08:00
|
|
|
[TestFixture, TestOf(typeof(AlertsSystem))]
|
2023-03-06 05:06:50 +00:00
|
|
|
public sealed class AlertManagerTests : RobustUnitTest
|
2020-11-09 20:22:19 -08:00
|
|
|
{
|
|
|
|
|
const string PROTOTYPES = @"
|
|
|
|
|
- type: alert
|
2022-04-03 02:01:22 +02:00
|
|
|
id: LowPressure
|
2022-07-28 11:17:51 +12:00
|
|
|
icons:
|
|
|
|
|
- /Textures/Interface/Alerts/Pressure/lowpressure.png
|
2020-11-09 20:22:19 -08:00
|
|
|
|
|
|
|
|
- type: alert
|
2022-04-03 02:01:22 +02:00
|
|
|
id: HighPressure
|
2022-07-28 11:17:51 +12:00
|
|
|
icons:
|
|
|
|
|
- /Textures/Interface/Alerts/Pressure/highpressure.png
|
2020-11-09 20:22:19 -08:00
|
|
|
";
|
|
|
|
|
|
|
|
|
|
[Test]
|
2022-01-05 00:19:23 -08:00
|
|
|
[Ignore("There is no way to load extra Systems in a unit test, fixing RobustUnitTest is out of scope.")]
|
2020-11-09 20:22:19 -08:00
|
|
|
public void TestAlertManager()
|
|
|
|
|
{
|
2023-03-06 05:06:50 +00:00
|
|
|
var entManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
var sysManager = entManager.EntitySysManager;
|
|
|
|
|
sysManager.LoadExtraSystemType<ClientAlertsSystem>();
|
|
|
|
|
var alertsSystem = sysManager.GetEntitySystem<ClientAlertsSystem>();
|
2021-03-05 01:08:38 +01:00
|
|
|
IoCManager.Resolve<ISerializationManager>().Initialize();
|
2022-01-05 00:19:23 -08:00
|
|
|
|
|
|
|
|
var reflection = IoCManager.Resolve<IReflectionManager>();
|
|
|
|
|
reflection.LoadAssemblies();
|
|
|
|
|
|
2020-11-09 20:22:19 -08:00
|
|
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
2021-09-04 14:13:34 +10:00
|
|
|
prototypeManager.Initialize();
|
2020-11-09 20:22:19 -08:00
|
|
|
prototypeManager.LoadFromStream(new StringReader(PROTOTYPES));
|
|
|
|
|
|
2024-05-23 22:43:04 -04:00
|
|
|
Assert.That(alertsSystem.TryGet("LowPressure", out var lowPressure));
|
|
|
|
|
Assert.That(lowPressure!.Icons[0], Is.EqualTo(new SpriteSpecifier.Texture(new ("/Textures/Interface/Alerts/Pressure/lowpressure.png"))));
|
|
|
|
|
Assert.That(alertsSystem.TryGet("HighPressure", out var highPressure));
|
|
|
|
|
Assert.That(highPressure!.Icons[0], Is.EqualTo(new SpriteSpecifier.Texture(new ("/Textures/Interface/Alerts/Pressure/highpressure.png"))));
|
2020-11-09 20:22:19 -08:00
|
|
|
|
2024-05-23 22:43:04 -04:00
|
|
|
Assert.That(alertsSystem.TryGet("LowPressure", out lowPressure));
|
|
|
|
|
Assert.That(lowPressure!.Icons[0], Is.EqualTo(new SpriteSpecifier.Texture(new ("/Textures/Interface/Alerts/Pressure/lowpressure.png"))));
|
|
|
|
|
Assert.That(alertsSystem.TryGet("HighPressure", out highPressure));
|
|
|
|
|
Assert.That(highPressure!.Icons[0], Is.EqualTo(new SpriteSpecifier.Texture(new ("/Textures/Interface/Alerts/Pressure/highpressure.png"))));
|
2020-11-09 20:22:19 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|