Fix build (#2830)
This commit is contained in:
parent
0063d30a85
commit
b208ff4c20
|
|
@ -1,15 +1,8 @@
|
|||
using System.IO;
|
||||
using Content.Server.Utility;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Interfaces;
|
||||
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.UnitTesting;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Tests.Shared.Alert
|
||||
|
|
@ -17,7 +10,8 @@ namespace Content.Tests.Shared.Alert
|
|||
[TestFixture, TestOf(typeof(AlertPrototype))]
|
||||
public class AlertPrototypeTests : ContentUnitTest
|
||||
{
|
||||
private const string PROTOTYPE = @"- type: alert
|
||||
private const string Prototypes = @"
|
||||
- type: alert
|
||||
alertType: HumanHealth
|
||||
category: Health
|
||||
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)));
|
||||
}
|
||||
|
||||
|
||||
[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(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)
|
||||
{
|
||||
|
||||
var alert = GetTestPrototype();
|
||||
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()
|
||||
{
|
||||
using (TextReader stream = new StringReader(PROTOTYPE))
|
||||
{
|
||||
var yamlStream = new YamlStream();
|
||||
yamlStream.Load(stream);
|
||||
var document = yamlStream.Documents[0];
|
||||
var rootNode = (YamlSequenceNode) document.RootNode;
|
||||
var proto = (YamlMappingNode) rootNode[0];
|
||||
var newReagent = new AlertPrototype();
|
||||
newReagent.LoadFrom(proto);
|
||||
return newReagent;
|
||||
}
|
||||
using TextReader stream = new StringReader(Prototypes);
|
||||
|
||||
var yamlStream = new YamlStream();
|
||||
yamlStream.Load(stream);
|
||||
|
||||
var document = yamlStream.Documents[0];
|
||||
var rootNode = (YamlSequenceNode) document.RootNode;
|
||||
var proto = (YamlMappingNode) rootNode[0];
|
||||
|
||||
var newReagent = new AlertPrototype();
|
||||
newReagent.LoadFrom(proto);
|
||||
|
||||
return newReagent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue