mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-09-15 14:52:30 +02:00
* Pass 1. * i'm FREE * Prevent hangups. * okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing. * sigh. * fix singular trigger bug so LatheTest doesn't flake. * Remove SystemAttribute usage. * Poke * I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls. * Change the faulty store test into two tests, one of which is ignored for failing.
82 lines
3.1 KiB
C#
82 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Content.IntegrationTests.Fixtures;
|
|
using Robust.Shared.Reflection;
|
|
using Robust.Shared.Serialization.Manager;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
using Robust.Shared.Serialization.Markdown.Value;
|
|
|
|
namespace Content.IntegrationTests.Tests.Serialization;
|
|
|
|
[TestFixture]
|
|
public sealed partial class SerializationTest : GameTest
|
|
{
|
|
/// <summary>
|
|
/// Check that serializing generic enums works as intended. This should really be in engine, but engine
|
|
/// integrations tests block reflection and I am lazy..
|
|
/// </summary>
|
|
[Test]
|
|
public async Task SerializeGenericEnums()
|
|
{
|
|
var pair = Pair;
|
|
var server = pair.Server;
|
|
var seriMan = server.ResolveDependency<ISerializationManager>();
|
|
var refMan = server.ResolveDependency<IReflectionManager>();
|
|
|
|
Enum value = TestEnum.Bb;
|
|
|
|
var node = seriMan.WriteValue(value, notNullableOverride: true);
|
|
var valueNode = node as ValueDataNode;
|
|
Assert.That(valueNode, Is.Not.Null);
|
|
|
|
var expected = refMan.GetEnumReference(value);
|
|
Assert.That(valueNode!.Value, Is.EqualTo(expected));
|
|
|
|
var errors = seriMan.ValidateNode<Enum>(valueNode).GetErrors();
|
|
Assert.That(errors.Any(), Is.False);
|
|
|
|
var deserialized = seriMan.Read<Enum>(node, notNullableOverride: true);
|
|
Assert.That(deserialized, Is.EqualTo(value));
|
|
|
|
// Repeat test with enums in a data definitions.
|
|
var data = new TestData
|
|
{
|
|
Value = TestEnum.Cc,
|
|
Sequence = [TestEnum.Dd, TestEnum.Aa]
|
|
};
|
|
|
|
node = seriMan.WriteValue(data, notNullableOverride: true);
|
|
|
|
errors = seriMan.ValidateNode<TestData>(node).GetErrors();
|
|
Assert.That(errors.Any(), Is.False);
|
|
|
|
var deserializedData = seriMan.Read<TestData>(node, notNullableOverride: false);
|
|
|
|
Assert.That(deserializedData.Value, Is.EqualTo(data.Value));
|
|
Assert.That(deserializedData.Sequence.Count, Is.EqualTo(data.Sequence.Count));
|
|
Assert.That(deserializedData.Sequence[0], Is.EqualTo(data.Sequence[0]));
|
|
Assert.That(deserializedData.Sequence[1], Is.EqualTo(data.Sequence[1]));
|
|
|
|
// Check that Generic & non-generic serializers are incompativle.
|
|
Enum genericValue = TestEnum.Bb;
|
|
TestEnum typedValue = TestEnum.Bb;
|
|
|
|
var genericNode = seriMan.WriteValue(genericValue, notNullableOverride: true);
|
|
var typedNode = seriMan.WriteValue(typedValue);
|
|
|
|
Assert.That(seriMan.ValidateNode<Enum>(genericNode).GetErrors().Any(), Is.False);
|
|
Assert.That(seriMan.ValidateNode<TestEnum>(genericNode).GetErrors().Any(), Is.True);
|
|
Assert.That(seriMan.ValidateNode<Enum>(typedNode).GetErrors().Any(), Is.True);
|
|
Assert.That(seriMan.ValidateNode<TestEnum>(typedNode).GetErrors().Any(), Is.False);
|
|
}
|
|
|
|
private enum TestEnum : byte { Aa, Bb, Cc, Dd }
|
|
|
|
[DataDefinition]
|
|
private sealed partial class TestData
|
|
{
|
|
[DataField] public Enum Value = default!;
|
|
[DataField] public List<Enum> Sequence = default!;
|
|
}
|
|
}
|