2021-02-11 01:13:03 -08:00
|
|
|
using System.IO;
|
2020-11-09 20:22:19 -08:00
|
|
|
using Content.Shared.Alert;
|
|
|
|
|
using NUnit.Framework;
|
2022-01-05 00:19:23 -08:00
|
|
|
using NUnit.Framework.Interfaces;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace Content.Tests.Shared.Alert
|
|
|
|
|
{
|
2022-01-05 00:19:23 -08:00
|
|
|
[TestFixture, TestOf(typeof(AlertsSystem))]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class AlertManagerTests : ContentUnitTest
|
2020-11-09 20:22:19 -08:00
|
|
|
{
|
|
|
|
|
const string PROTOTYPES = @"
|
|
|
|
|
- type: alert
|
2021-02-20 00:05:24 +01:00
|
|
|
name: AlertLowPressure
|
2020-11-09 20:22:19 -08:00
|
|
|
alertType: LowPressure
|
|
|
|
|
icon: /Textures/Interface/Alerts/Pressure/lowpressure.png
|
|
|
|
|
|
|
|
|
|
- type: alert
|
2021-02-20 00:05:24 +01:00
|
|
|
name: AlertHighPressure
|
2020-11-09 20:22:19 -08:00
|
|
|
alertType: HighPressure
|
|
|
|
|
icon: /Textures/Interface/Alerts/Pressure/highpressure.png
|
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
[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()
|
|
|
|
|
{
|
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));
|
|
|
|
|
|
2022-01-05 00:19:23 -08:00
|
|
|
Assert.That(EntitySystem.Get<AlertsSystem>().TryGet(AlertType.LowPressure, out var lowPressure));
|
2020-12-23 23:42:48 +01:00
|
|
|
Assert.That(lowPressure.Icon, Is.EqualTo(new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/Alerts/Pressure/lowpressure.png"))));
|
2022-01-05 00:19:23 -08:00
|
|
|
Assert.That(EntitySystem.Get<AlertsSystem>().TryGet(AlertType.HighPressure, out var highPressure));
|
2020-12-23 23:42:48 +01:00
|
|
|
Assert.That(highPressure.Icon, Is.EqualTo(new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/Alerts/Pressure/highpressure.png"))));
|
2020-11-09 20:22:19 -08:00
|
|
|
|
2022-01-05 00:19:23 -08:00
|
|
|
Assert.That(EntitySystem.Get<AlertsSystem>().TryGet(AlertType.LowPressure, out lowPressure));
|
2020-12-23 23:42:48 +01:00
|
|
|
Assert.That(lowPressure.Icon, Is.EqualTo(new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/Alerts/Pressure/lowpressure.png"))));
|
2022-01-05 00:19:23 -08:00
|
|
|
Assert.That(EntitySystem.Get<AlertsSystem>().TryGet(AlertType.HighPressure, out highPressure));
|
2020-12-23 23:42:48 +01:00
|
|
|
Assert.That(highPressure.Icon, Is.EqualTo(new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/Alerts/Pressure/highpressure.png"))));
|
2020-11-09 20:22:19 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|