Fix and add test for PrototypeManager LoadString (#1574)

This commit is contained in:
DrSmugleaf
2021-02-20 01:43:43 +01:00
committed by GitHub
parent 2409965cf8
commit a9b163992b
2 changed files with 18 additions and 1 deletions

View File

@@ -397,7 +397,7 @@ namespace Robust.Shared.Prototypes
public List<IPrototype> LoadString(string str)
{
return LoadFromStream(new StreamReader(str));
return LoadFromStream(new StringReader(str));
}
#endregion IPrototypeManager members

View File

@@ -12,7 +12,9 @@ namespace Robust.UnitTesting.Shared.Prototypes
[TestFixture]
public class PrototypeManager_Test : RobustUnitTest
{
private const string LoadStringTestDummyId = "LoadStringTestDummy";
private IPrototypeManager manager = default!;
[OneTimeSetUp]
public void Setup()
{
@@ -97,6 +99,16 @@ namespace Robust.UnitTesting.Shared.Prototypes
Assert.That(prototype.PlacementMode, Is.EqualTo("SnapgridCenter"));
}
[Test]
public void TestLoadString()
{
manager.LoadString(LoadStringDocument);
var prototype = manager.Index<EntityPrototype>(LoadStringTestDummyId);
Assert.That(prototype.Name, Is.EqualTo(LoadStringTestDummyId));
}
private enum YamlTestEnum : byte
{
Foo,
@@ -159,6 +171,11 @@ namespace Robust.UnitTesting.Shared.Prototypes
placement:
mode: SnapgridCenter
";
private static readonly string LoadStringDocument = $@"
- type: entity
id: {LoadStringTestDummyId}
name: {LoadStringTestDummyId}";
}
public class TestBasicPrototypeComponent : Component