* Give .props files 2-space indents.
* Move to Central Package Management.
Allows us to store NuGet package versions all in one place. Yay!
* Update NuGet packages and fix code for changes.
Notable:
Changes to ILVerify.
Npgsql doesn't need hacks for inet anymore, now we need hacks to make the old code work with this new reality.
NUnit's analyzers are already complaining and I didn't even update it to 4.x yet.
TerraFX changed to GetLastSystemError so error handling had to be changed.
Buncha APIs have more NRT annotations.
* Remove dotnet-eng NuGet package source.
I genuinely don't know what this was for, and Central Package Management starts throwing warnings about it, so YEET.
* Remove Robust.Physics project.
Never used.
* Remove erroneous NVorbis reference.
Should be VorbisPizza and otherwise wasn't used.
* Sandbox fixes
* Remove unused unit test package references.
Castle.Core and NUnit.ConsoleRunner.
* Update NUnit to 4.0.1
This requires replacing all the old assertion methods because they removed them 🥲
* Oh so that's what dotnet-eng was used for. Yeah ok that makes sense.
* Add Robust.Analyzers.Test
* Update submodule
* commit to re-run CI
81 lines
3.3 KiB
C#
81 lines
3.3 KiB
C#
using System.IO;
|
|
using Content.Server.Alert;
|
|
using Content.Shared.Alert;
|
|
using NUnit.Framework;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.Manager;
|
|
|
|
namespace Content.Tests.Shared.Alert
|
|
{
|
|
[TestFixture]
|
|
[TestOf(typeof(AlertsComponent))]
|
|
public sealed class ServerAlertsComponentTests : ContentUnitTest
|
|
{
|
|
const string PROTOTYPES = @"
|
|
- type: alert
|
|
id: LowPressure
|
|
category: Pressure
|
|
icon: /Textures/Interface/Alerts/Pressure/lowpressure.png
|
|
|
|
- type: alert
|
|
id: HighPressure
|
|
category: Pressure
|
|
icon: /Textures/Interface/Alerts/Pressure/highpressure.png
|
|
";
|
|
|
|
[Test]
|
|
[Ignore("There is no way to load extra Systems in a unit test, fixing RobustUnitTest is out of scope.")]
|
|
public void ShowAlerts()
|
|
{
|
|
// this is kind of unnecessary because there's integration test coverage of Alert components
|
|
// but wanted to keep it anyway to see what's possible w.r.t. testing components
|
|
// in a unit test
|
|
|
|
var entManager = IoCManager.Resolve<IEntityManager>();
|
|
IoCManager.Resolve<ISerializationManager>().Initialize();
|
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
|
prototypeManager.Initialize();
|
|
var factory = IoCManager.Resolve<IComponentFactory>();
|
|
factory.RegisterClass<AlertsComponent>();
|
|
prototypeManager.LoadFromStream(new StringReader(PROTOTYPES));
|
|
prototypeManager.ResolveResults();
|
|
|
|
var entSys = entManager.EntitySysManager;
|
|
entSys.LoadExtraSystemType<ServerAlertsSystem>();
|
|
|
|
var alertsComponent = new AlertsComponent();
|
|
alertsComponent = IoCManager.InjectDependencies(alertsComponent);
|
|
|
|
Assert.That(EntitySystem.Get<AlertsSystem>().TryGet(AlertType.LowPressure, out var lowpressure));
|
|
Assert.That(EntitySystem.Get<AlertsSystem>().TryGet(AlertType.HighPressure, out var highpressure));
|
|
|
|
EntitySystem.Get<AlertsSystem>().ShowAlert(alertsComponent.Owner, AlertType.LowPressure, null, null);
|
|
|
|
var getty = new ComponentGetState();
|
|
entManager.EventBus.RaiseComponentEvent(alertsComponent, getty);
|
|
|
|
var alertState = (AlertsComponent.AlertsComponent_AutoState) getty.State!;
|
|
Assert.That(alertState, Is.Not.Null);
|
|
Assert.That(alertState.Alerts.Count, Is.EqualTo(1));
|
|
Assert.That(alertState.Alerts.ContainsKey(lowpressure.AlertKey));
|
|
|
|
EntitySystem.Get<AlertsSystem>().ShowAlert(alertsComponent.Owner, AlertType.HighPressure, null, null);
|
|
|
|
// Lazy
|
|
entManager.EventBus.RaiseComponentEvent(alertsComponent, getty);
|
|
alertState = (AlertsComponent.AlertsComponent_AutoState) getty.State!;
|
|
Assert.That(alertState.Alerts.Count, Is.EqualTo(1));
|
|
Assert.That(alertState.Alerts.ContainsKey(highpressure.AlertKey));
|
|
|
|
EntitySystem.Get<AlertsSystem>().ClearAlertCategory(alertsComponent.Owner, AlertCategory.Pressure);
|
|
|
|
entManager.EventBus.RaiseComponentEvent(alertsComponent, getty);
|
|
alertState = (AlertsComponent.AlertsComponent_AutoState) getty.State!;
|
|
Assert.That(alertState.Alerts.Count, Is.EqualTo(0));
|
|
}
|
|
}
|
|
}
|