using System.Collections.Generic; using System.IO; using NetSerializer; using NUnit.Framework; namespace Robust.UnitTesting.Shared.Serialization { // Tests NetSerializer itself because we have specific modifications. // e.g. (at the time of writing) list serialization being more compact. [Parallelizable(ParallelScope.All)] public class NetSerializer_Test { public static readonly List?[] ListValues = { null, new List(), new List {1, 2, 3}, }; [Test] public void TestList([ValueSource(nameof(ListValues))] List? list) { var serializer = new Serializer(new[] {typeof(List)}); var stream = new MemoryStream(); serializer.SerializeDirect(stream, list); stream.Position = 0; serializer.DeserializeDirect?>(stream, out var deserialized); if (list == null) { Assert.Null(deserialized); } else { Assert.That(deserialized, Is.EquivalentTo(list)); } } } }