Files
tbd-station-14/Content.IntegrationTests/Tests/Chemistry/FixedPoint2SerializationTest.cs
Tayrtahn cfc0247e5c Code Cleanup: Integration Tests (#29584)
* Cleanup PuddleTest

* Cleanup GravityGridTest

* Cleanup PowerTest

* Cleanup SaveLoadMapTest

* Cleanup Body tests

* Cleanup ContainerOcclusionTest

* Cleanup AirlockTest

* Cleanup DamageableTest

* Cleanup EntityTest

* Cleanup FluidSpillTest

* Cleanup FollowerSystemTest

* Cleanup HandCuffTest

* Cleanup InteractionSystemTests

* Cleanup InRangeUnobstructed

* Cleanup SimplePredictReconcileTest

* Cleanup PostMapInitTest

* Cleanup SalvageTest

* Cleanup SaveLoadSaveTest

* Cleanup ShuttleTest

* Cleanup MaterialArbitrageTest

* Cleanup PrototypeSaveTest

* Fix ShuttleTest

* Bunch of small ones

* Move JobTests to Station directory

* More small fixes

* Cleanup InteractionTest.Helpers
Had to change a method signature, so some callers were modified too.

* Missed one
2024-07-03 10:01:37 +10:00

59 lines
1.8 KiB
C#

using System.Reflection;
using Content.Shared.FixedPoint;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Value;
using Robust.UnitTesting.Shared.Serialization;
namespace Content.IntegrationTests.Tests.Chemistry
{
public sealed class FixedPoint2SerializationTest : SerializationTest
{
protected override Assembly[] Assemblies =>
[
typeof(FixedPoint2SerializationTest).Assembly
];
[Test]
public void DeserializeNullTest()
{
var node = ValueDataNode.Null();
var unit = Serialization.Read<FixedPoint2?>(node);
Assert.That(unit, Is.Null);
}
[Test]
public void SerializeNullTest()
{
var node = Serialization.WriteValue<FixedPoint2?>(null);
Assert.That(node.IsNull);
}
[Test]
public void SerializeNullableValueTest()
{
var node = Serialization.WriteValue<FixedPoint2?>(FixedPoint2.New(2.5f));
#pragma warning disable NUnit2045 // Interdependent assertions
Assert.That(node is ValueDataNode);
Assert.That(((ValueDataNode) node).Value, Is.EqualTo("2.5"));
#pragma warning restore NUnit2045
}
[Test]
public void DeserializeNullDefinitionTest()
{
var node = new MappingDataNode().Add("unit", ValueDataNode.Null());
var definition = Serialization.Read<FixedPoint2TestDefinition>(node);
Assert.That(definition.Unit, Is.Null);
}
}
[DataDefinition]
public sealed partial class FixedPoint2TestDefinition
{
[DataField] public FixedPoint2? Unit { get; set; } = FixedPoint2.New(5);
}
}