serv4 + submodule update (#12740)

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Paul Ritter
2022-11-27 19:25:55 +01:00
committed by GitHub
parent 7608c24b63
commit 3884c4d3db
46 changed files with 230 additions and 302 deletions

View File

@@ -18,16 +18,31 @@ namespace Content.IntegrationTests.Tests.Chemistry
[Test]
public void DeserializeNullTest()
{
var node = new ValueDataNode("null");
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));
Assert.That(node is ValueDataNode);
Assert.That(((ValueDataNode)node).Value, Is.EqualTo("2.5"));
}
[Test]
public void DeserializeNullDefinitionTest()
{
var node = new MappingDataNode().Add("unit", "null");
var node = new MappingDataNode().Add("unit", ValueDataNode.Null());
var definition = Serialization.Read<FixedPoint2TestDefinition>(node);
Assert.That(definition.Unit, Is.Null);

View File

@@ -213,18 +213,14 @@ public sealed class PrototypeSaveTest
}
private sealed class TestEntityUidContext : ISerializationContext,
ITypeSerializer<EntityUid, ValueDataNode>,
ITypeReaderWriter<EntityUid, ValueDataNode>
ITypeSerializer<EntityUid, ValueDataNode>
{
public Dictionary<(Type, Type), object> TypeReaders { get; }
public Dictionary<Type, object> TypeWriters { get; }
public Dictionary<Type, object> TypeCopiers => TypeWriters;
public Dictionary<(Type, Type), object> TypeValidators => TypeReaders;
public SerializationManager.SerializerProvider SerializerProvider { get; }
public TestEntityUidContext()
{
TypeReaders = new() { { (typeof(EntityUid), typeof(ValueDataNode)), this } };
TypeWriters = new() { { typeof(EntityUid), this } };
SerializerProvider = new();
SerializerProvider.RegisterSerializer(this);
}
ValidationNode ITypeValidator<EntityUid, ValueDataNode>.Validate(ISerializationManager serializationManager,
@@ -245,16 +241,9 @@ public sealed class PrototypeSaveTest
ValueDataNode node,
IDependencyCollection dependencies,
bool skipHook,
ISerializationContext? context, EntityUid _)
ISerializationContext? context, ISerializationManager.InstantiationDelegate<EntityUid>? instanceProvider = null)
{
return EntityUid.Invalid;
}
public EntityUid Copy(ISerializationManager serializationManager, EntityUid source, EntityUid target,
bool skipHook,
ISerializationContext? context = null)
{
return new((int) source);
}
}
}