Add prototype serialization tests. (#18458)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2023-08-06 14:47:45 +12:00
committed by GitHub
parent b97be440dd
commit 28a5e32f5e
18 changed files with 138 additions and 53 deletions

View File

@@ -40,7 +40,7 @@ public sealed class PrototypeSaveTest
[Test]
public async Task UninitializedSaveTest()
{
// Apparently SpawnTest fails to clean up properly. Due to the similarities, I'll assume this also fails.
// Apparently SpawnTest fails to clean up properly. Due to the similarities, I'll assume this also fails.
await using var pairTracker = await PoolManager.GetServerClient();
var server = pairTracker.Pair.Server;
@@ -190,14 +190,14 @@ public sealed class PrototypeSaveTest
await pairTracker.CleanReturnAsync();
}
private sealed class TestEntityUidContext : ISerializationContext,
public sealed class TestEntityUidContext : ISerializationContext,
ITypeSerializer<EntityUid, ValueDataNode>
{
public SerializationManager.SerializerProvider SerializerProvider { get; }
public bool WritingReadingPrototypes { get; set; }
public string WritingComponent = string.Empty;
public EntityPrototype Prototype = default!;
public EntityPrototype? Prototype;
public TestEntityUidContext()
{
@@ -215,7 +215,7 @@ public sealed class PrototypeSaveTest
IDependencyCollection dependencies, bool alwaysWrite = false,
ISerializationContext? context = null)
{
if (WritingComponent != "Transform" && !Prototype.NoSpawn)
if (WritingComponent != "Transform" && (Prototype?.NoSpawn == false))
{
// Maybe this will be necessary in the future, but at the moment it just indicates that there is some
// issue, like a non-nullable entityUid data-field. If a component MUST have an entity uid to work with,