Fix build (#2830)
This commit is contained in:
@@ -1,15 +1,8 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
using Content.Server.Utility;
|
using System.IO;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Interfaces;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Robust.Shared.Interfaces.Log;
|
|
||||||
using Robust.Shared.Interfaces.Reflection;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Log;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.UnitTesting;
|
|
||||||
using YamlDotNet.RepresentationModel;
|
using YamlDotNet.RepresentationModel;
|
||||||
|
|
||||||
namespace Content.Tests.Shared.Alert
|
namespace Content.Tests.Shared.Alert
|
||||||
@@ -17,7 +10,8 @@ namespace Content.Tests.Shared.Alert
|
|||||||
[TestFixture, TestOf(typeof(AlertPrototype))]
|
[TestFixture, TestOf(typeof(AlertPrototype))]
|
||||||
public class AlertPrototypeTests : ContentUnitTest
|
public class AlertPrototypeTests : ContentUnitTest
|
||||||
{
|
{
|
||||||
private const string PROTOTYPE = @"- type: alert
|
private const string Prototypes = @"
|
||||||
|
- type: alert
|
||||||
alertType: HumanHealth
|
alertType: HumanHealth
|
||||||
category: Health
|
category: Health
|
||||||
icon: /Textures/Interface/Alerts/Human/human.rsi/human.png
|
icon: /Textures/Interface/Alerts/Human/human.rsi/human.png
|
||||||
@@ -34,32 +28,50 @@ namespace Content.Tests.Shared.Alert
|
|||||||
Assert.That((new AlertKey(AlertType.Buckled, AlertCategory.Health)), Is.EqualTo(AlertKey.ForCategory(AlertCategory.Health)));
|
Assert.That((new AlertKey(AlertType.Buckled, AlertCategory.Health)), Is.EqualTo(AlertKey.ForCategory(AlertCategory.Health)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TestCase(0, "/Textures/Interface/Alerts/Human/human.rsi/human0.png")]
|
[TestCase(0, "/Textures/Interface/Alerts/Human/human.rsi/human0.png")]
|
||||||
[TestCase(null, "/Textures/Interface/Alerts/Human/human.rsi/human0.png")]
|
|
||||||
[TestCase(1, "/Textures/Interface/Alerts/Human/human.rsi/human1.png")]
|
[TestCase(1, "/Textures/Interface/Alerts/Human/human.rsi/human1.png")]
|
||||||
[TestCase(6, "/Textures/Interface/Alerts/Human/human.rsi/human6.png")]
|
[TestCase(6, "/Textures/Interface/Alerts/Human/human.rsi/human6.png")]
|
||||||
[TestCase(7, "/Textures/Interface/Alerts/Human/human.rsi/human6.png")]
|
|
||||||
public void GetsIconPath(short? severity, string expected)
|
public void GetsIconPath(short? severity, string expected)
|
||||||
{
|
{
|
||||||
|
|
||||||
var alert = GetTestPrototype();
|
var alert = GetTestPrototype();
|
||||||
Assert.That(alert.GetIcon(severity), Is.EqualTo(new SpriteSpecifier.Texture(new ResourcePath(expected))));
|
Assert.That(alert.GetIcon(severity), Is.EqualTo(new SpriteSpecifier.Texture(new ResourcePath(expected))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(null, "/Textures/Interface/Alerts/Human/human.rsi/human0.png")]
|
||||||
|
[TestCase(7, "/Textures/Interface/Alerts/Human/human.rsi/human1.png")]
|
||||||
|
public void GetsIconPathThrows(short? severity, string expected)
|
||||||
|
{
|
||||||
|
var alert = GetTestPrototype();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
alert.GetIcon(severity);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
Assert.Pass();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Assert.Fail($"Unexpected exception: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private AlertPrototype GetTestPrototype()
|
private AlertPrototype GetTestPrototype()
|
||||||
{
|
{
|
||||||
using (TextReader stream = new StringReader(PROTOTYPE))
|
using TextReader stream = new StringReader(Prototypes);
|
||||||
{
|
|
||||||
var yamlStream = new YamlStream();
|
var yamlStream = new YamlStream();
|
||||||
yamlStream.Load(stream);
|
yamlStream.Load(stream);
|
||||||
var document = yamlStream.Documents[0];
|
|
||||||
var rootNode = (YamlSequenceNode) document.RootNode;
|
var document = yamlStream.Documents[0];
|
||||||
var proto = (YamlMappingNode) rootNode[0];
|
var rootNode = (YamlSequenceNode) document.RootNode;
|
||||||
var newReagent = new AlertPrototype();
|
var proto = (YamlMappingNode) rootNode[0];
|
||||||
newReagent.LoadFrom(proto);
|
|
||||||
return newReagent;
|
var newReagent = new AlertPrototype();
|
||||||
}
|
newReagent.LoadFrom(proto);
|
||||||
|
|
||||||
|
return newReagent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user